Databases - Online Test

Q1. Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic values. 
F = {CH → G, A → BC, B → CFH, E → A, F → EG} is a set of functional dependencies (FDs) so that F+ is exactly the set of FDs that hold for R
How many candidate keys does the relation R have?
Answer : Option B
Explaination / Solution:

Candidate keys are AD, BD, ED and FD

Q2. Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic values. 
F = {CH → G, A → BC, B → CFH, E → A, F → EG} is a set of functional dependencies (FDs) so that F+ is exactly the set of FDs that hold for R
The relation R is
Answer : Option A
Explaination / Solution:

A → BC,B → CFH and F → EG are partial dependencies. Hence it is in 1NF but not in 2NF

Q3. The Gross Domestic Product (GDP) in Rupees grew at 7% during 2012-2013. For international comparison, the GDP is compared in US Dollars (USD) after conversion based on the market exchange rate. During the period 2012-2013 the exchange rate for the USD increased from Rs. 50/ USD to Rs. 60/ USD. India’s GDP in USD during the period 2012- 2013
Answer : Option D
Explaination / Solution:

Per 100 Rs final value 107 Rs 
⇒ Per 100/50 Dollars final value 107/60
for 100 dollars____? 
= ((100 × 50)/100) × (107/60) = 89.16
Decreased by 11%. 

Q4. What is the optimized version of the relation algebra expression  where A1, A2 are sets of attributes in with A⊂ Aand F1, F2 are Boolean expressions based on
Answer : Option A
Explaination / Solution:
No Explaination.


Q5. A prime attribute of a relation scheme R is an attribute that appears
Answer : Option B
Explaination / Solution:

A prime attribute or key attribute of a relation scheme R is an attribute that appears in any of the candidate key of R, remaining attributes are known as non-prime or non-key tribute

Q6. Consider the transactions T1, T2, and T3 and the schedules S1 and S2 given below.
T1 : r1 (X) ; r1 (z) ; w1 (X) ; w1 (z) 
T2 : r2 (X) ; r2 (z) ; w2 (z) 
T3 : r3 (X) ; r3 (X) ; w3 (Y) 
S1: r1(X); r3(Y); r3(X); r2(Y); r2(Z); w3(Y); w2(Z); r1(Z); w1(X); w1(Z) 
S2: r1(X); r3(Y); r2(Y); r3(X); r1(Z); r2(Z); w3(Y); w1(X); w2(Z); w1(Z) 
Which one of the following statements about the schedules is TRUE?
Answer : Option A
Explaination / Solution:

Precedence graph for S1 & S2 are as follows 

∴Only S1 is conflict serializable.

Q7.  Consider the relational schema given below, where eId of the relation dependentis a foreign key referring to empId of the relation employee. Assume that every employee has at least one associated dependent in the dependent relation.
employee (empId, empName, empAge)
dependent (depId, eId, depName, depAge)
Consider the following relational algebra query

The above query evaluates to the set of empIds of employees whose age is greater than that of 
Answer : Option D
Explaination / Solution:


Part A of the above given relational algebra query will give the set of empIds of those employees whose age is less than or equal to the age of some of his/her dependents. Now when set of empIds of all employees minus set of empIds obtained from part A is done, then we get the set of empIds of employees whose age is greater than that of all of his/her dependents.  

Q8.  Consider the decision problem 2CNFSAT defined as follows:
{ φ | φ is a satisfiable propositional formula in CNF with at most two literal per clause}
For example,  is a Boolean formula and it is in 2CNFSAT.
The decision problem 2CNFSAT is
Answer : Option B
Explaination / Solution:

2 SAT is in P. This we can prove by reducing 2 SAT to directed graph reachability problem which is known to be in P. 
Procedure for reducing 2 SAT to reachability problem:
1. Let ϕ be CNF with clauses of length 2 and let P be the set of propositional variables(literals) in ϕ
2. Build a graph G=(V,E) with V= P { p|p P} ∪ ¬ ∈ and (x, y E )∈ iff there is a clause in ϕ that is equivalent to x y → (all the clauses are converted to equivalent implications and the graph built is called as implication graph)
3. Observe that ϕ is unsatisfiable iff there is a p P ∈ such that there is both a path from p to to ¬p and from ¬p to p in G.
This condition can be tested by running the reachability algorithm several times.

Q9. Consider the following transaction involving two bank account x and y. read (x) ; x : = x – 50; write (x) ; read (y); y : = y + 50 ; write (y) The constraint that the sum of the accounts x and y should remain constant is that of
Answer : Option B
Explaination / Solution:

The consistency property ensures that the database remains in a consistent state before the (start of the transaction and after the transaction is over. Here sum of the accounts x & y should remain same before & after execution of the given transactions which refers to the consistency of the sum.

Q10. Consider the following two statements.
S1 : if a candidate is known to be corrupt, then he will not be elected 
S2 : if a candidate is kind, he will be elected
Which one of the following statements follows from S1 and S2 per sound interference rules of logic? 
Answer : Option C
Explaination / Solution:

Let P: candidate known to be corrupt q: candidate will be elected r: candidate is kind S1 = p ⟶ ~ q = q ⟶~p S2 = r ⟶ q i.e., If a person is kind, he is not known to be corrupt Option is C