Mock
Mock
Weeks 1 to 8
1. Kiran was born on 19 Janurary, 1980. His date of birth was registered in the municipal
corporation database on 21 January, 1980.
Considering that the municipal corporation database is a temporal database, which
among the following statements is true.
[MCQ:2points]
√
19 Janurary, 1980 is a valid time which provides historical information, whereas
21 January, 1980 is a transaction time which provides rollback information.
⃝ 19 Janurary, 1980 is a valid time which provides rollback information, whereas
21 January, 1980 is a transaction time which provides historical information.
⃝ 19 Janurary, 1980 is a transaction time which provides rollback information,
whereas 21 January, 1980 is a valid time which provides historical information.
⃝ 19 Janurary, 1980 is a transaction time which provides historical information,
whereas 21 January, 1980 is a valid time which provides rollback information.
Solution:
• 19 Janurary, 1980 is time when actual event took place. Thus, it is the valid
time and provides historical information.
• 21 January, 1980 is the time when event information is entered into the tam-
poral database. Thus, it is transaction time and provides rollback information.
Page 2
2. Consider the relational schema R(A, B, C, D), where the domains of A, B, C and D
include only atomic values. Identify the sets of functional dependencies satisfied by R
such that R is in BCNF.
[MSQ:2points]
√
FD: {ABC → D, AD → BC}
⃝ FD: {AB → CD, CD → B, D → A}
√
FD: {A → B, B → C, C → D, D → A}
⃝ FD: {AB → D, D → B, D → C, C → A}
Solution:
For FD: {ABC → D, AD → BC}, since (ABC)+ = ABCD and (AD)+ = ABCD,
ABC and AD are superkeys. Thus, it is in BCNF.
For FD: {AB → CD, CD → B, D → A}, since (D)+ = AD, D is not superkey in
FD D → A . Thus, it is not BCNF.
For FD: {A → B, B → C, C → D, D → A} , since (A)+ = ABCD, (B)+ = ABCD,
(C)+ = ABCD, (D)+ = ABCD, A, B, C, D all are superkeys . Thus, it is in BCNF.
For FD: {AB → D, D → B, D → C, C → A} , since (C)+ = CA, C is not superkey
in FD C → A . Thus, it is not BCNF.
Page 3
3. Which among the following methods of psycopg2 is/are used to execute SQL statements?
[MSQ:2points]
√
cursor.execute()
√
cursor.executemany()
⃝ cursor.fetchall()
⃝ cursor.fetchmany()
Solution:
The methods cursor.execute() and cursor.executemany() are used to execute
an SQL statement.
Whereas, cursor.fetchall() fetches all the rows and cursor.fetchmany() fetches
next n (required to pass as an argument in the method) rows from a query result.
Page 4
4. Consider a relation R(A, B, C, D, E, F, G, H, I, J) having functional dependencies as
follows F = {AB → C, B → F, D → IJ, A → DE, F → GH}.
Then, which among the following is a lossless decomposition of R? [MCQ:4 Points]
⃝ R1 (A, B, C, I, J), R2 (D, E, F ) and R3 (G, H, I)
⃝ R1 (A, B, C), R2 (D, E, F ), R3 (G, H) and R4 (D, I, J)
√
R1 (A, B, C), R2 (A, D, E), R3(B, F ), R4 (F, G, H) and R5 (D, I, J)
⃝ R1 (A, B, C, D), R2 (D, E), R3 (B, F ), R4 (F, G, H) and R5 (D, I, J)
Solution:
Option 1: R1(A, B, C, I, J), R2(D, E, F ) and R3(G, H, I) is a lossy decomposition.
• R1 ∪ R2 ∪ R3 = R
• R1 ∪ R2 ∪ R3 ∪ R4 = R
• But, R1 ∩ R3 = ϕ
• R1 ∪ R2 ∪ R3 ∪ R4 ∪ R5 = R
• R1 ∪ R2 ∪ R3 ∪ R4 ∪ R5 = R
Page 5
• R1 ∩ R3 = B, by using B → F, we can determine R3. Let R13 = R1 ∪ R3 =
(A, B, C, D, F)
Page 6
5. A database designer observes that a relation R is in 2NF, and has transitive functional
dependencies. Relation R is then decomposed into relations R1 and R2, such that the
decomposition is 3NF and lossless. Now, the designer observes that, R2 is in 3NF
but not in BCNF. Relation R2 is further decomposed into R3 and R4 such that the
decomposition is in BCNF, and it satisfies the following conditions:
• R2 = R3 ∪ R4
• R3 ∩ R4 → R3
Solution:
• From the given conditions, we can say that decomposition of R2 into R3 and
R4 is lossless. Since it is lossless decomposition, The number of tuples in R2 is
equal to the number of tuples in (R3 ⋊ ⋉ R4) i.e., R2 = R3 ⋊
⋉ R4.
Page 7
6. Find the equivalent SQL statement corresponding to the below relational algebraic ex-
pression :
[ MCQ: 2 points]
Πemp name σemployee.dept id=department.dept id ∧ dept name=′ F inance′ (employee × department)
⃝ select emp_name from employee, department
where dept_name=‘Finance’;
⃝ select e.emp_name from employee e, department d
where d.dept_name=‘Finance’;
⃝ select e.emp_name from employee e, department d
where e.dept_id=d.dept_id or d.dept_name=‘Finance’;
√
select e.emp_name from employee e, department d
where e.dept_id=d.dept_id and d.dept_name=‘Finance’;
Πemp name σemployee.dept id=department.dept id ∧ dept name=′ F inance′ (employee×department)
will project down the employee names.
Option 1, Option 2 and Option 3 will give incorrect results, i.e., they fetch the
wrong employee names.
Option 4 will give the name of only those employees who work in the ’Finance’
department.
Page 8
7. Let R(V, W, X, Y, Z) be a given relation with the following functional dependencies:
F = {V → W, W X → Z, Y Z → V }
Then, which among the following is/are the candidate key(s)?
[MSQ: 3 points]
⃝ XY
√
W XY
√
V XY
⃝ VW
Solution: Consider the closure of each set of attributes given in the options. We can
see that the closures of options 2 and 3 contain all attributes. So, both W XY and
V XY are super keys. Since both W XY and V XY are minimal, both are candidate
keys.
Page 9
8. Consider relational instance given in Figure 1.
[MCQ: 2 points]
Which of the following functional dependencies does not hold on the given table?
⃝ V → WX
⃝ YZ →X
√
X →YZ
⃝ WY → Z
Page 10
9. In the relational schema given below, all attributes take atomic values only.
R(bike name, bike model, bike engine no)
Solution:
1.Attributes(R1) ∪ Attributes(R2) = R
2.Attributes(R1) ∩ Attributes(R2) ̸= ϕ
3. bike model is a candidate key of R2 table
So, decomposition is lossless
Page 11
10. Consider the relation R(M, N, O, P, Q) with the functional dependency set
F ={N → P, Q → M, OP → Q, M → N O}.
[MSQ:3 points]
Page 12
11. Consider a relation R(I, J, K, L, M, N ) with the following set of functional dependencies.
F ={IK → N, L → M N, JK → L, KN → JL, IKL → J, KM → IN }
From among the following options, choose all the sets of functional dependencies which
serve as canonical covers of F on R.
[MSQ: 4 points]
⃝ FC ={L → M N, JK → L, KM → I, KM → N }
√
FC ={L → M N, JK → L, KM → I, IK → N, KN → J}
⃝ FC ={L → M N, JK → L, KM → IJ, IK → J}
√
FC ={L → M N, JK → L, KM → I, IK → J, KN → L}
Solution: Refer slide 24.15, 24.16 for the algorithm to find canonical cover.
Page 13
12. Pseudo-transitivity is a derived Armstrong’s axiom. From among the options, select
those basic Armstrong’s axiom(s) which are used to derive the pseudo-transitivity axiom.
[MSQ: 2 points]
⃝ Composition Axiom
⃝ Decomposition Axiom
√
Transitivity Axiom
√
Augmentation Axiom
Page 14
13. Consider a string of pending block references in the order given: 3, 2, 4, 1, 3, 2, 4, 1, 4, 2.
The system has a buffer with 3 slots. Assume that initially the buffer is empty. If LRU
buffer replacement policy is used, then what will be a number of misses and number of
hits?
(2 ∗ Number of misses) + (3 ∗ Number of hits)
[NAT: 4 points]
Answer: 22
Solution:
In the given block reference order of 10 blocks, the first 8 block references would be
miss, only the last 2 block reference would be hit when LRU replacement algorithm
is used.
Accordingly, the answer would be :
2 ∗ 8 + 3 ∗ 2 = 22
Page 15
14. Consider the Binary Search Tree (BST) shown in Figure 2.
Which of the following is/are the correct insertion order(s) which will result in the given
BST? [MSQ: 4 points]
⃝ 64, 31, 20, 52, 10, 96, 98, 69, 84, 25, 79
√
64, 31, 20, 52, 10, 96, 25, 79, 84, 98, 69
⃝ 64, 31, 20, 52, 10, 84, 98, 25, 79, 69, 96
⃝ 64, 31, 20, 52, 10, 84, 25, 69, 96, 98, 79
Solution: Option 1: 64, 31, 20, 52, 10, 96, 98, 69, 84, 25, 79 will result in :
Option 2: 64, 31, 20, 52, 10, 96, 25, 79, 84, 98, 69 will result in :
Page 16
Option 3: 64, 31, 20, 52, 10, 84, 98, 25, 79, 69, 96 will result in:
Option 4: 64, 31, 20, 52, 10, 84, 25, 69, 96, 98, 79 will result in:
Page 17
15. Consider a disk having 128 tracks per surface, 512 sectors per track and 256 bytes/sector.
If the minimum number of bits required to access a sector is 21, then find out the number
of platters required? [NAT: 3 points]
Ans: 16
Page 18
16. Consider a relation R(A, B, C, D, E ) with the following multivalued dependencies:
• A →→ B
• B →→ D
Suppose relation R contains the tuples (0, 1, 2, 3, 4) and (0, 5, 6, 7, 8). Which of the
following tuple(s) must also be in R? [ MSQ: 4 points]
⃝ (0, 1, 2, 7, 8)
√
(0, 5, 6, 3, 8)
√
(0, 1, 6, 7, 8)
⃝ (0, 1, 6, 3, 4)
Solution: First consider the two given tuples. Try to apply the given MVDs to any
pair of tuples that have the same values for the attributes on the left side of the
MVD.
Each application of an MVD lets you add two tuples to the relation: the tuples
formed by swapping the values for the attributes on the right side of the MVD.
This can be done using the formal definition of an MVD. Repeat this process until
all the tuples implied by the MVDs are already in the relation.
Page 19
17. Which of the following components of MVC is/are responsible for receiving events, pro-
cessing and generating a view for the user?
[MSQ: 2 points]
⃝ View
⃝ Model
√
Controller
⃝ All of these
• controller: receives events, executes actions, and returns a view to the user
Page 20