Gate DBMS
Gate DBMS
Gate DBMS
ER‐model. Relational model:Relational algebra, Tuple calculus, SQL. Integrity constraints, Normal forms. File organization,
Indexing (e.g., B and B+ trees). Transactions and concurrency control.
The below figure shows a B+ tree where only key values are indicated in the records. Each block can hold upto three records.
A record with a key value 34 is inserted into the B+ tree. Obtain the modified B+ tree after insertion.
Answer ☟
Consider B+ - tree of order d shown in figure. (A B+ - tree of order d contains between d and 2d keys in each node)
Draw the resulting B+ - tree after 100 is inserted in the figure below.
Answer ☟
For a B+ - tree of order d with n leaf nodes, the number of nodes accessed during a search is O(_).
Answer ☟
A B+ - tree of order d is a tree in which each internal node has between d and 2d key values. An internal node with M key
values has M + 1 children. The root (if it is an internal node) has between 1 and 2d key values. The distance of a node from the
root is the length of the path from the root to the node. All leaves are at the same distance from the root. The height of the tree is the
distance of a leaf from the root.
+
Answer ☟
A. B-trees are for storing data on disk and B+ trees are for main memory.
B. Range queries are faster on B+ trees.
C. B-trees are for primary indexes and B+ trees are for secondary indexes.
D. The height of a B+ tree is independent of the number of records.
Answer ☟
Consider a B-tree with degree m, that is, the number of children, c, of any internal node (except the root) is such that
m ≤ c ≤ 2m − 1 . Derive the maximum and minimum number of records in the leaf nodes for such a B-tree with height
h, h ≥ 1.( Assume that the root of a tree is at height 0).
Answer ☟
3.1.7 B Tree: GATE CSE 2000 | Question: 1.22, UGCNET-June2012-II: 11 top☝ ☛ https://gateoverflow.in/646
Answer ☟
(a) Suppose you are given an empty B+ tree where each node (leaf and internal) can store up to 5 key values. Suppose values
1, 2, … 10 are inserted, in order, into the tree. Show the tree pictorially
Answer ☟
We wish to construct a B+ tree with fan-out (the number of pointers per node) equal to 3 for the following set of key values:
80, 50, 10, 70, 30, 100, 90
Assume that the tree is initially empty and the values are added in the order given.
a. Show the tree after insertion of 10, after insertion of 30, and after insertion of 90. Intermediate trees need not be shown.
b. The key values 30 and 10 are now deleted from the tree in that order show the tree after each deletion.
Answer ☟
a. The following table refers to search items for a key in B-trees and B+ trees.
B-tree B+ -tree
Successful search Unsuccessful search Successful search Unsuccessful search
X1 X2 X3 X4
A successful search means that the key exists in the database and unsuccessful means that it is not present in the database.
Each of the entries X1 , X2 , X3 and X4 can have a value of either Constant or Variable. Constant means that the search time
is the same, independent of the specific key value, where variable means that it is dependent on the specific key value chosen
for the search.
Give the correct values for the entries X1 , X2 , X3 and X4 (for example X1 = Constant,
X2 = Constant , X3 = Constant, X4 = Constant)
b. Relation R(A, B) has the following view defined on it:
CREATE VIEW V AS
(SELECT R1.A,R2.B
FROM R AS R1, R as R2
WHERE R1.B=R2.A)
i. The current contents of relation R are shown below. What are the contents of the view V ?
A B
1 2
2 3
2 4
4 5
6 7
6 8
9 10
ii. The tuples (2, 11) and (11, 6) are now inserted into R. What are the additional tuples that are inserted in V ?
Answer ☟
3.1.11 B Tree: GATE CSE 2002 | Question: 2.23, UGCNET-June2012-II: 26 top☝ ☛ https://gateoverflow.in/853
A B+ - tree index is to be built on the Name attribute of the relation STUDENT. Assume that all the student names are of
length 8 bytes, disk blocks are of size 512 bytes, and index pointers are of size 4 bytes. Given the scenario, what would be the best
choice of the degree (i.e. number of pointers per node) of the B+ - tree?
16
Answer ☟
Consider the following 2 − 3 − 4 tree (i.e., B-tree with a minimum degree of two) in which each data item is a letter. The
usual alphabetical ordering of letters is used in constructing the tree.
A.
B.
C.
D. None of the above
Answer ☟
The order of an internal node in a B+ tree index is the maximum number of children it can have. Suppose that a child pointer
takes 6 bytes, the search field value takes 14 bytes, and the block size is 512 bytes. What is the order of the internal node?
A. 24
B. 25
C. 26
D. 27
Answer ☟
Which of the following is a key factor for preferring B+ -trees to binary search trees for indexing database relations?
Answer ☟
3.1.15 B Tree: GATE CSE 2007 | Question: 63, ISRO2016-59 top☝ ☛ https://gateoverflow.in/1261
The order of a leaf node in a B+ - tree is the maximum number of (value, data record pointer) pairs it can hold. Given that the
block size is 1K bytes, data record pointer is 7 bytes long, the value field is 9 bytes long and a block pointer is 6 bytes long,
what is the order of the leaf node?
A. 63
B. 64
C. 67
D. 68
Answer ☟
A B-tree of order 4 is built from scratch by 10 successive insertions. What is the maximum number of node splitting
operations that may take place?
A. 3
B. 4
C. 5
D. 6
Answer ☟
The following key values are inserted into a B+ - tree in which order of the internal nodes is 3, and that of the leaf nodes is 2,
in the sequence given below. The order of internal nodes is the maximum number of tree pointers in each node, and the order of leaf
nodes is the maximum number of data items that can be stored in it. The B+ - tree is initially empty
10, 3, 6, 8, 4, 2, 1
The maximum number of times leaf nodes would get split up as a result of these insertions is
A. 2
B. 3
C. 4
D. 5
Answer ☟
Consider a B+ -tree in which the maximum number of keys in a node is 5. What is the minimum number of keys in any non-
root node?
A. 1
B. 2
C. 3
D. 4
Answer ☟
With reference to the B+ tree index of order 1 shown below, the minimum number of nodes (including the Root node) that
must be fetched in order to satisfy the following query. "Get all records with a search key greater than or equal to 7 and less than 15
" is ______.
Answer ☟
Consider a B+ tree in which the search key is 12 byte long, block size is 1024 byte , recorder pointer is 10 byte long and the
block pointer is 8 byte long. The maximum number of keys that can be accommodated in each non-leaf node of the tree is ______.
Answer ☟
A. The lengths of the paths from the root to all leaf nodes are all equal.
B. The lengths of the paths from the root to all leaf nodes differ from each other by at most 1.
C. The number of children of any two non-leaf sibling nodes differ by at most 1.
D. The number of records in any two leaf nodes differ by at most 1.
Answer ☟
In a B+ Tree , if the search-key value is 8 bytes long , the block size is 512 bytes and the pointer size is 2 B , then the
maximum order of the B+ Tree is ____
Answer ☟
Which one of the following statements is NOT correct about the B+ tree data structure used for creating an index of a
Answer ☟
Consider a table T in a relational database with a key field K . A B-tree of order p is used as an access structure on K , where
p denotes the maximum number of tree pointers in a B-tree index node. Assume that K is 10 bytes long; disk block size is 512
bytes ; each data pointer PD is 8 bytes long and each block pointer PB is 5 bytes long. In order for each B-tree node to fit in a single
disk block, the maximum value of p is
A. 20
B. 22
C. 23
D. 32
Answer ☟
A B-Tree used as an index for a large database table has four levels including the root node. If a new key is inserted in this
index, then the maximum number of nodes that could be newly created in the process are
A. 5
B. 4
C. 3
D. 2
Answer ☟
In a database file structure, the search key field is 9 bytes long, the block size is 512 bytes , a record pointer is 7 bytes and a
block pointer is 6 bytes . The largest possible order of a non-leaf node in a B+ tree implementing this file structure is
A. 23
B. 24
C. 34
D. 44
Answer ☟
Consider the B+ tree in the adjoining figure, where each node has at most two keys and three links.
A. 1
B. 2
C. 3
D. 4
Answer ☟
Consider the B+ tree in the adjoining figure, where each node has at most two keys and three links.
Keys K15 and then K25 are inserted into this tree in that order. Now the key K50 is deleted from the B+ tree resulting after the
two insertions made earlier. Consider the following statements about the B+ tree resulting after this deletion.
Answer ☟
Answers: B Tree
B+ tree Reference.
In a B+ tree only the leaf nodes have a pointer to actual data (record pointers) whereas internal nodes points to index blocks.
In the given question we have
To insert 34 we’ll first place it in the sorted order among the leaf nodes.
Now, we see that the block (being the leaf node the pointers here are record pointers) having 34 is overflowing and so we’ll split
it and move the center element to the parent block. There might be a confusion as to whether 34 or 50 should move up, but if we
see the question it is following right biasing (same key value is going to the right) and so 50 must move up.
Now, we have an overflow in the internal node as the maximum capacity of an internal node is 3 block pointers but we are
having 4 here. So we must again split and move 50 upwards.
Now we have an overflow in the root node and so we must again split and move 120 upwards making a new root.
Now all the B+ tree requirements are satisfied and so the insertion algorithm terminates.
References
For the given B+ tree, d = 2 ⟹ 2d = 4. Also right biasing is followed as 69 is to the right of 69 in the parent node.
We’ll insert 100 in the sorted position among the leaf nodes.
This again causes an overflow at the root node and 69 needs to be moved up forming a new root. Here, 69 is not a record pointer
(only leaf nodes in B+ tree contains record pointers) and so we need not replicate it while moving up.
Now all the property of B+ tree is satisfied and the insertion algorithm terminates.
For n leaves we have n − 1 keys in the internal node. (see 'part a' of this question)
Total keys in internal nodes = n − 1, each node can have keys between d and 2d.
Let us understand specification of B+ tree first
For a non-root node
A. False. Both r stored in disk
B. True. By searching leaf level linearly in B+ tree, we can say a node is present or not in B+ tree. But for B tree we have to
traverse the whole tree
D. False. Height depends on number of record and also max no of keys in each node (order of tree)
Correct Answer: B
References
Given a B tree :
Answer is (B). The major advantage of B+ tree is in reducing the number of last level access which would be from disk
in case of large data size.
http://stackoverflow.com/questions/15485220/advantage-of-b-trees-over-bsts
References
A.i)
A.ii)
i. In normal case: Insertion always will be done at the rightmost leaf node, and all nodes will have exact
m+1
⌊ 2 ⌋ keys expect this rightmost leaf ( no of keys can vary from
m+1
⌊ 2 ⌋ to m for rightmost leaf).
(There are two possible answers for this part, I left it on the reader to find out the second one)
Because all nodes will have
m+1
⌊ 2 ⌋ keys except 1 rightmost node.
n
Average number of keys in leaf would be: ⎢ ⎥
⎢ ⎥
⎢ ⎥
⎢ n
⎥
⎣ ⌊ ⌋⎦
m+1
2
(b)
p
Underflow: if leaf node contain ⌈ 2 ⌉ − 1 = 2 − 1 = 1 key values.
Deletion of key-value 30 :
Here when we delete the key-value 10 then underflow happened, so we can merge this node with the right sibling.
When we merge two nodes then the parent node one value needs to come down i.e. 50 here.
Now if we try to bring 50 down then that node will again suffer from underflow as it will become empty.
so we will try to merge this node it with its right sibling i.e. the node which contains 70
Again, When we merge two nodes(nodes in the 2nd level that contain 50 and 70) then one value of the parent node (i.e. node
having 50, 70 ) needs to come down
So we will bring 70 down and merge it with 50 since bringing 70 down will not cause underflow as 80 is present in the parent
node.
For A)
For Part B) i) Write down two copies of the same table for comparison side by side. Just map B of first to A of the second copy.
Those matching tuples take A of first table & B of seconds.
Content of View A
A B
1 3
1 4
2 5
A B
11 7
11 8
2 6
1 11
3.1.11 B Tree: GATE CSE 2002 | Question: 2.23, UGCNET-June2012-II: 26 top☝ ☛ https://gateoverflow.in/853
Answer: C
In a B+ tree we want en entire node content to be in a disk block. A node can contain up to p pointers to child nodes and up to
p − 1 key values for a B+ tree of order p . Here, key size is 8 bytes and index pointer size is 4 bytes. Now a B+ tree has
different structure for internal node and leaf nodes. While internal nodes can have upto p − 1 key values and p child pointers,
leaf node will have one sibling pointer in addition to maximum p − 1 keys and p − 1 record pointers. Since our key is Name
attribute which is not assumed to be unique it must be a secondary index and hence the record pointer must be an index pointer
to primary index. This will ensure size of a leaf node is same as the size of a non-leaf node. Hence for a maximum sized node we
can write
(B) is the correct answer.
Once we add G, the leaf node becomes B G H I , since we can have only 3 keys. the node has to split at G or H , and G or H
will be added to parent node.
Since P is the parent node in options 1 and 2, its evident the 3rd element i.e. H should be selected for splitting (because after
adding any key from the leftmost child node, P becomes the 3rd element in the node)
Now parent node becomes H L P U , select P as for splitting, and you get option B.
Hence, answer is B.
Answer: C
14(p − 1) + 6p ≤ 512
20p − 14 ≤ 512
20p ≤ 526
Therefore, p = 26 .
32 votes -- Rajarshi Sarkar (27.9k points)
Answer: D
3.1.15 B Tree: GATE CSE 2007 | Question: 63, ISRO2016-59 top☝ ☛ https://gateoverflow.in/1261
The answer is option A.
Bp + P(Rp + Key) ≤ BlockSize
⟹ 1 × 6 + n(7 + 9) ≤ 1024
⟹ n ≤ 63.625.
So, 63 is the answer.
Total 5 splitting will occur during 10 successive insertions
Let's take 10 successive key values as {1, 2, 3, … 10} which can cause maximum possible splits.
In this question they have asked only to count leaf node splits.
So, after discussing with my friends on Facebook, I found that you will get two different answers depending on which
convention you follow.
Convention 1: put the middle element in the left node, if you follow this you will get 4 as answer.
Convention 2: put the middle element in the right node, if you follow this you will get 3 as answer.
4 splits:
Correct Answer: C
Answer: B
Order = 5+1 = 6
6
Minimum children in a non root node = ⌈ Order
2 ⌉=⌈ 2 ⌉=3
Keys = Minimum children in a non root node - 1 = 2
62 votes -- Rajarshi Sarkar (27.9k points)
whichever way you go from the root to leaves, you'll always end up counting 5 nodes.
(n − 1)12 + n × 8 ≤ 1024
n ≤ 51
= 51 − 1 = 50
63 votes -- ppm (543 points)
Option A: In
B+ Tree all leaves are at same level.
In both B Tree and B+ trees, depth (length of root to leaf paths) of all leaf nodes is same. This is made sure by the insertion and
deletion operations. In these trees, we do insertions in a way that if we have increase height of tree after insertion, we increase
height from the root. This is different from BST where height increases from leaf nodes. Similarly, if we have to decrease height
after deletion, we move the root one level down. This is also different from BST which shrinks from the bottom. The above ways
of insertion and deletion make sure that depth of every leaf node is same.
Let order of B+ tree is p then maximum number of child pointers = p and maximum number of keys = p − 1 .
To accommodate all child pointers and search key, total size of these together can not exceed 512 bytes .
2(p) + 8(p − 1) ≤ 512
⟹ p ≤ 52
Therefore, maximum order must be 52.
Properties of B+ trees:
1. B+ tree is height balance tree.
2. Key value is in sorted order.
3. Leaf node has pointer to next leaf node.
4. Non leaf node has pointer to a node (leaf or non leaf) and not pointer to data record.
It is 23.
Suppose all nodes are completely full means every node has n − 1 keys. tree has 4 levels if a new key is inserted then at
every level there will be created a new node. and in worst case root node will also be broken into two parts. and we have 4 levels
so, answer should be 5 because tree will be increased with one more level.
Correct Answer: A
Answer is (C).
So, n × p + (n − 1)k ≤ B
n × 6 + (n − 1) × 9 ≤ 512
⟹ n ≤ 34.77
Option (A) is correct.
It is a B+ Tree.
After inserting K15 we get
So, we see in the final tree only (K20, K25) is present. Hence, 1 (Ans).
3.2.1 Candidate Keys: GATE CSE 1994 | Question: 3.7 top☝ ☛ https://gateoverflow.in/2493
An instance of a relational scheme R(A, B, C) has distinct values for attribute A. Can you conclude that A is a candidate key
for R?
Answer ☟
Consider a relational table with a single record for each registered student with the following attributes:
Answer ☟
3.2.3 Candidate Keys: GATE CSE 2014 Set 2 | Question: 21 top☝ ☛ https://gateoverflow.in/1978
The maximum number of superkeys for the relation schema R(E, F, G, H) with E as the key is _____.
Answer ☟
For (StudentName, StudentAge) to be a key for this instance, the value X should NOT be equal to______.
Answer ☟
3.2.5 Candidate Keys: GATE CSE 2014 Set 3 | Question: 22 top☝ ☛ https://gateoverflow.in/2056
Answer ☟
3.2.1 Candidate Keys: GATE CSE 1994 | Question: 3.7 top☝ ☛ https://gateoverflow.in/2493
No.
A B C
1 5 6
2 4 7
3 4 5
Answer is (A)
A relation is given (Registration_Num, UID, BankAccount_Num, Name, Hostel_Room).
Now, Registration_Num is unique for each student. So with this, we can identify each student. Hence, this can be the primary
key.
UID: It's an identification number for a person in a country. (Say you're in India and your UID is 0243. Someone in Pakistan
If S is a super key then S ∪ UID will be a Super key. e.g. R(A, B, C, D), If AB is a superkey then ABC, ABCD are also
superkey.
BankAccount_Num is not a candidate key, because a student can have multiple accounts or joint accounts. We can not identify
each student uniquely with BankAccount_Num.
3.2.3 Candidate Keys: GATE CSE 2014 Set 2 | Question: 21 top☝ ☛ https://gateoverflow.in/1978
Super Key is any set of attributes that uniquely determines a tuple in a relation.
Since E is the only key, E should be present in any super key.
Excluding E, there are three attributes in the relation, namely F, G, H . Hence, if we add E to any subset of those three
attributes, then the resulting set is a super key. Number of subsets of {F, G, H} is 8. Hence the answer is
8.
⎧
⎪
⎪ ⎫
⎪
⎪
⎪ ⎪
E
EF
⎨ ⎬
EG
⎪ ⎪
EH
⎩
⎪ ⎭
⎪
EFG
EFH
EGH
EFGH
3.2.4 Candidate Keys: GATE CSE 2014 Set 2 | Question: 22 top☝ ☛ https://gateoverflow.in/1980
Should not eqaul to 19.
Since if it is equal the same key will have two different values for "StudentEmail" which cannot be true by the definition of
candidate/primary/super key.
43 votes -- Aravind (2.8k points)
3.2.5 Candidate Keys: GATE CSE 2014 Set 3 | Question: 22 top☝ ☛ https://gateoverflow.in/2056
Answer (B).
The attributes of a candidate key are called the prime attributes. Suppose ABC is one candidate key of a Relation
R(ABCDEFGH). Then the attributes A, B and C all are prime attributes. Similarly if ABD is also another candidate key in
the same relation R, then D is also a prime attribute. And conversely, an attribute that does not occur in ANY candidate key is
called a non-prime attribute.
18 votes -- Divya Bharti (8.8k points)
3.3.1 Conflict Serializable: GATE CSE 2017 Set 2 | Question: 44 top☝ ☛ https://gateoverflow.in/118640
where ri (V ) denotes a read operation by transaction Ti on a variable V and wi (V ) denotes a write operation by transaction Ti on
a variable V . The total number of conflict serializable schedules that can be formed by T1 and T2 is ______
3.3.2 Conflict Serializable: GATE CSE 2021 Set 1 | Question: 32 top☝ ☛ https://gateoverflow.in/357419
Let ri (z) and wi (z) denote read and write operations respectively on a data item z by a transaction Ti . Consider the following
two schedules.
Answer ☟
3.3.3 Conflict Serializable: GATE CSE 2021 Set 2 | Question: 32 top☝ ☛ https://gateoverflow.in/357508
Let S be the following schedule of operations of three transactions T1 , T2 and T3 in a relational database system:
P : S is conflict-serializable.
Q: If T3 commits before T1 finishes, then S is recoverable.
Answer ☟
3.3.1 Conflict Serializable: GATE CSE 2017 Set 2 | Question: 44 top☝ ☛ https://gateoverflow.in/118640
There is only one way to have (conflict) serializable schedule as T 1 → T 2, because last operation of T 1 and first
operation of T 2 conflicts each other.
I am writing T 1−
W(C) and R(C) do not have any conflict with any operation, but W(B) has.
Pick each case and see,how many positions other operation of T 2 can take.
(note that these W(C) and R(C) cant come before W(B) )
that is 5C1 + 5C2 = 15 (either both can take same space or two different spaces)
Now see, for each of these 15 positions, how many can R(B) take ?
that is 4C1 + 4C2 = 10 (either both can take same space or two different spaces)
Now see, for each of these 10 positions, how many can R(B) take ?
Now see, for each of these 6 positions, how many can R(B) take ?
3.3.2 Conflict Serializable: GATE CSE 2021 Set 1 | Question: 32 top☝ ☛ https://gateoverflow.in/357419
T1 T2
r1 (x)
r1 (y)
r2 (x)
r2 (y)
w2 (y)
w1 (x)
Here r1 (y) and w2 (y) are conflicting pairs, giving T1 → T2 and r2 (x) and w1 (x) giving T2 → T1 , so the schedule is not
conflict serializable.
Here r2 (x) and w2 (x) are conflicting pairs giving T2 → T1 , and w2 (y) and r1 (y) also giving T2 → T1 , therefore this schedule
is conflict serializable.
Correct Option B
3.3.3 Conflict Serializable: GATE CSE 2021 Set 2 | Question: 32 top☝ ☛ https://gateoverflow.in/357508
T1 T2 T3
R(Y )
R(X)
R(Z)
R(Y )
W (X)
R(Z)
W (Y )
R(X)
W (Z)
There are no other conflicts and the discovered conflicts are not forming the cycle.
Therefore, the given schedule is Conflict Serializable.
Statement Q : If T3 commits, before T1 finishes, then S is recoverable.
' Schedule S is recoverable, if Tj creating the dirty read by reading the written data by Ti and Tj commits after Ti
commits.
3.4.1 Data Independence: GATE CSE 1994 | Question: 3.11 top☝ ☛ https://gateoverflow.in/2497
Answer ☟
This is False.
Generally, physical data independence exists in most databases and file environments where physical details are hidden from the
user and applications remain unaware of these details. On the other hand, logical data independence is harder to achieve because
of a much stricter requirement - it allows structural and constraint changes without affecting application programs.
A relation r with schema (X, Y ) satisfies the function dependency X → Y , The tuples ⟨1, 2⟩ and ⟨2, 2⟩ can both be in r
simultaneously.
Answer ☟
3.5.2 Database Normalization: GATE CSE 1988 | Question: 12i top☝ ☛ https://gateoverflow.in/94398
What are the three axioms of functional dependency for the relational databases given by Armstrong.
Answer ☟
3.5.3 Database Normalization: GATE CSE 1988 | Question: 12iia top☝ ☛ https://gateoverflow.in/94399
{x → y, x → z} ∣= x → yz
Answer ☟
3.5.4 Database Normalization: GATE CSE 1988 | Question: 12iib top☝ ☛ https://gateoverflow.in/94618
{x → y, wy → z} ∣= xw → z
Answer ☟
3.5.5 Database Normalization: GATE CSE 1988 | Question: 12iic top☝ ☛ https://gateoverflow.in/94619
{x → y, z ⊂ y} ∣= x → z
3.5.6 Database Normalization: GATE CSE 1990 | Question: 2-iv top☝ ☛ https://gateoverflow.in/83977
Answer ☟
3.5.7 Database Normalization: GATE CSE 1990 | Question: 3-ii top☝ ☛ https://gateoverflow.in/84054
Answer ☟
3.5.8 Database Normalization: GATE CSE 1994 | Question: 3.6 top☝ ☛ https://gateoverflow.in/2492
There is always a decomposition into Boyce-Codd normal form (BCNF) that is lossless and dependency preserving.
Answer ☟
Consider the relation scheme R(A, B, C) with the following functional dependencies:
A, B → C,
C→A
Answer ☟
3.5.10 Database Normalization: GATE CSE 1997 | Question: 6.9 top☝ ☛ https://gateoverflow.in/2265
For a database relation R(a, b, c, d) , where the domains a, b, c, d include only atomic values, only the following functional
dependencies and those that can be inferred from them hold
a→c
b→d
This relation is
Answer ☟
3.5.11 Database Normalization: GATE CSE 1998 | Question: 1.34 top☝ ☛ https://gateoverflow.in/1671
Which normal form is considered adequate for normal relational database design?
A. 2NF
B. 5NF
C. 4NF
D. 3NF
Answer ☟
Book_id
Subject_Category_of_book
Name_of_Author
Nationality_of_Author
Answer ☟
3.5.13 Database Normalization: GATE CSE 1999 | Question: 1.24 top☝ ☛ https://gateoverflow.in/1477
Answer ☟
3.5.14 Database Normalization: GATE CSE 1999 | Question: 2.7, UGCNET-June2014-III: 25 top☝ ☛ https://gateoverflow.in/1485
Consider the schema R = (S, T , U, V ) and the dependencies S → T , T → U, U → V and V → S . Let R = (R1 and R2)
be a decomposition such that R1 ∩ R2 ≠ ϕ . The decomposition is
A. not in 2NF
B. in 2NF but not 3NF
C. in 3NF but not in 2NF
D. in both 2NF and 3NF
Answer ☟
3.5.15 Database Normalization: GATE CSE 2000 | Question: 2.24 top☝ ☛ https://gateoverflow.in/671
X Y Z
1 4 2
1 5 3
1 6 3
3 2 2
Answer ☟
3.5.16 Database Normalization: GATE CSE 2001 | Question: 2.23 top☝ ☛ https://gateoverflow.in/741
R(A, B, C, D) is a relation. Which of the following does not have a lossless join, dependency preserving BCNF
decomposition?
A. A → B, B → CD
B. A → B, B → C, C → D
C. AB → C, C → AD
D. A → BCD
Answer ☟
3.5.17 Database Normalization: GATE CSE 2002 | Question: 1.19 top☝ ☛ https://gateoverflow.in/824
Relation R with an associated set of functional dependencies, F , is decomposed into BCNF . The redundancy (arising out of
functional dependencies) in the resulting set of relations is
A. Zero
B. More than zero but less than that of an equivalent 3NF decomposition
C. Proportional to the size of F+
D. Indeterminate
Answer ☟
Answer ☟
3.5.19 Database Normalization: GATE CSE 2002 | Question: 2.24 top☝ ☛ https://gateoverflow.in/854
Relation R is decomposed using a set of functional dependencies, F , and relation S is decomposed using another set of
functional dependencies, G. One decomposition is definitely BCNF , the other is definitely 3NF , but it is not known which is
which. To make a guaranteed identification, which one of the following tests should be used on the decompositions? (Assume that
the closures of F and G are available).
A. Dependency-preservation
B. Lossless-join
C. BCNF definition
D. 3NF definition
Answer ☟
3.5.20 Database Normalization: GATE CSE 2002 | Question: 2.25 top☝ ☛ https://gateoverflow.in/855
From the following instance of a relation schema R(A, B, C) , we can conclude that:
A B C
1 1 1
1 1 0
2 3 2
2 3 2
Answer ☟
Answer ☟
The relation scheme Student Performance (name, courseNo, rollNo, grade) has the following functional dependencies:
Answer ☟
3.5.23 Database Normalization: GATE CSE 2005 | Question: 29, UGCNET-June2015-III: 9 top☝ ☛ https://gateoverflow.in/1365
Answer ☟
Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional dependencies hold: {A → B,
BC → D , E → C , D → A}. What are the candidate keys R?
A. AE, BE
B. AE, BE, DE
C. AEH, BEH, BCH
D. AEH, BEH, DEH
Answer ☟
AB → CD, AF → D, DE → F, C → G, F → E, G → A
A. {CF}∗ = {ACDEFG}
B. {BG}∗ = {ABCDG}
C. {AF}∗ = {ACDEFG}
D. {AB}∗ = {ABCDG}
Answer ☟
3.5.26 Database Normalization: GATE CSE 2007 | Question: 62, UGCNET-June2014-II: 47 top☝ ☛ https://gateoverflow.in/1260
Answer ☟
Assume { Author, Title } is the key for both schemes. Which of the following statements is true?
Answer ☟
Answer ☟
Answer ☟
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?
A. 3
B. 4
C. 5
D. 6
Answer ☟
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
A. in 1NF , but not in 2NF .
B. in 2NF , but not in 3NF .
C. in 3NF , but not in BCNF .
D. in BCNF .
Answer ☟
3.5.32 Database Normalization: GATE CSE 2014 Set 1 | Question: 21 top☝ ☛ https://gateoverflow.in/1788
Consider the relation scheme R = (E, F, G, H, I, J, K, L, M, N) and the set of functional dependencies
{{E, F} → {G}, {F} → {I, J}, {E, H} → {K, L}, {K} → {M}, {L} → {N}}
A. {E, F}
B. {E, F, H}
C. {E, F, H, K, L}
D. {E}
Answer ☟
3.5.33 Database Normalization: GATE CSE 2014 Set 1 | Question: 30 top☝ ☛ https://gateoverflow.in/1797
Answer ☟
3.5.34 Database Normalization: GATE CSE 2015 Set 3 | Question: 20 top☝ ☛ https://gateoverflow.in/8420
Consider the relation X(P, Q, R, S, T , U) with the following set of functional dependencies
F = { {P, R} → {S, T }, {P, S, U} → {Q, R} }
Which of the following is the trivial functional dependency in F + , where F + is closure to F?
A. {P, R} → {S, T }
B. {P, R} → {R, T }
C. {P, S} → {S}
D. {P, S, U} → {Q}
Answer ☟
3.5.35 Database Normalization: GATE CSE 2016 Set 1 | Question: 21 top☝ ☛ https://gateoverflow.in/39637
A. V XY Z
B. V WXZ
C. V WXY
D. V WXY Z
Answer ☟
3.5.36 Database Normalization: GATE CSE 2016 Set 1 | Question: 23 top☝ ☛ https://gateoverflow.in/39646
Answer ☟
The following functional dependencies hold true for the relational schema R {V , W, X, Y , Z} :
V→W
VW → X
Y → VX
Y→Z
Which of the following is irreducible equivalent for this set of functional dependencies?
A. V → W
V→X
Y→V
Y→Z
B. V → W
W→X
Y→V
Y→Z
C. V → W
V→X
Y→V
Y→X
Y→Z
D. V → W
W→X
Y→V
Y→X
Y→Z
Answer ☟
Consider the following four relational schemas. For each schema , all non-trivial functional dependencies are listed, The
bolded attributes are the respective primary keys.
Schema I: Registration(rollno, courses)
Field ‘courses’ is a set-valued attribute containing the set of courses a student has registered for.
Non-trivial functional dependency
rollno → courses
Schema II: Registration (rollno, coursid, email)
Non-trivial functional dependencies:
rollno, courseid → email
email → rollno
Schema III: Registration (rollno, courseid, marks, grade)
Non-trivial functional dependencies:
rollno, courseid, → marks, grade
marks → grade
Schema IV: Registration (rollno, courseid, credit)
Non-trivial functional dependencies:
rollno, courseid → credit
courseid → credit
Which one of the relational schemas above is in 3NF but not in BCNF?
A. Schema I
B. Schema II
C. Schema III
D. Schema IV
Answer ☟
Let the set of functional dependencies F = {QR → S, R → P, S → Q} hold on a relation schema X = (PQRS) . X is
not in BCNF. Suppose X is decomposed into two schemas Y and Z , where Y = (PR) and Z = (QRS) .
Consider the two statements given below.
Answer ☟
Consider a relational table R that is in 3NF , but not in BCNF. Which one of the following statements is TRUE?
A. R has a nontrivial functional dependency X → A , where X is not a superkey and A is a prime attribute.
B. R has a nontrivial functional dependency X → A , where X is not a superkey and A is a non-prime attribute and X
is not a proper subset of any key.
C. R has a nontrivial functional dependency X → A , where X is not a superkey and A is a non-prime attribute and X
is a proper subset of some key
D. A cell in R holds a set instead of an atomic value.
Answer ☟
3.5.41 Database Normalization: GATE CSE 2021 Set 1 | Question: 33 top☝ ☛ https://gateoverflow.in/357418
PQ → X; P → Y X; Q → Y; Y → ZW
Consider the decomposition of the relation R into the constituent relations according to the following two decomposition schemes.
Answer ☟
3.5.42 Database Normalization: GATE CSE 2021 Set 2 | Question: 40 top☝ ☛ https://gateoverflow.in/357500
Suppose the following functional dependencies hold on a relation U with attributes P, Q, R, S , and T :
Which of the following functional dependencies can be inferred from the above functional dependencies?
A. PS → T
B. R→T
C. P→R
D. PS → Q
Answer ☟
A relation Empdtl is defined with attributes empcode (unique), name, street, city, state and pincode. For any pincode, there is
only one city and state. Also, for any given street, city and state, there is just one pincode. In normalization terms, Empdtl is a
relation in
A. 1NF only
B. 2NF and hence also in 1NF
C. 3NF and hence also in 2NF and 1NF
D. BCNF and hence also in 3NF , 2NF and 1NF
Answer ☟
F1 → F3 , F2 → F4 , (F1 . F2 ) → F5
Answer ☟
In a schema with attributes A, B, C, D and E following set of functional dependencies are given
A→B
A→C
CD → E
B→D
E→A
Which of the following functional dependencies is NOT implied by the above set?
A. CD → AC
B. BD → CD
C. BC → CD
D. AC → BC
Answer ☟
Consider a relation R with five attributes V , W, X, Y , and Z. The following functional dependencies hold:
V Y → W, WX → Z, and ZY → V .
Which of the following is a candidate key for R?
A. V XZ
B. V XY
C. V WXY
D. V WXY Z
Answer ☟
Answer ☟
Let R(A, B, C, D, E, P, G) be a relational schema in which the following functional dependencies are known to hold:
AB → CD, DE → P, C → E, P → C and B → G. The relational schema R is
A. in BCNF
B. in 3NF , but not in BCNF
C. in 2NF , but not in 3NF
D. not in 2NF
Answer ☟
Consider a schema R(A, B, C, D) and functional dependencies A → B and C → D. Then the decomposition of R into
R1 (A, B) and R2 (C, D) is
Answer ☟
True is answer.
X → Y says when X repeats, Y will be also repeat. Since, X is not repeated, Y may or may not repeat.
3.5.2 Database Normalization: GATE CSE 1988 | Question: 12i top☝ ☛ https://gateoverflow.in/94398
1. AXIOM OF REFLEXIVITY
If Y ⊆ X then X → Y
2. AXIOM OF AUGMENTATION
3. AXIOM OF TRANSITIVITY
If X → Y and Y → Z then X → Z
12 votes -- Aashish (1.8k points)
3.5.3 Database Normalization: GATE CSE 1988 | Question: 12iia top☝ ☛ https://gateoverflow.in/94399
x → z (Given)
Also x → y (Given)
xx → yz (Axiom of transitivity)
⟹ x → yz
9 votes -- Satbir Singh (21k points)
3.5.4 Database Normalization: GATE CSE 1988 | Question: 12iib top☝ ☛ https://gateoverflow.in/94618
x → y (Given)
also yw → z (Given)
3.5.5 Database Normalization: GATE CSE 1988 | Question: 12iic top☝ ☛ https://gateoverflow.in/94619
∵ z ⊂ y , Trivially y → z . Now by transitivity, x → y, y → z ⟹ x → z
6 votes -- Arkaprava Paul (1.9k points)
3.5.6 Database Normalization: GATE CSE 1990 | Question: 2-iv top☝ ☛ https://gateoverflow.in/83977
Secondary index ⇒ B-tree
3.5.7 Database Normalization: GATE CSE 1990 | Question: 3-ii top☝ ☛ https://gateoverflow.in/84054
C. Not in 3NF because let us suppose ABC is a candidate key ( you can assume any candidate key with any no of attribute) .
now consider AB -> non-prime attribute which shows it is not in 3NF
D. involving only prime attribute so the Right side should definitely contain only prime attribute. therefore it is in 3NF
so B, D is the answer
Edited on 24th Nov 2020 by Gurdeep saini
3.5.8 Database Normalization: GATE CSE 1994 | Question: 3.6 top☝ ☛ https://gateoverflow.in/2492
False
BCNF decomposition can always be lossless, but it may not be always possible to get a dependency preserving BCNF
decomposition.
38 votes -- Sourav Roy (2.9k points)
The Candidate Keys are AB and BC .
None of the given functional dependencies are partial. So, the scheme qualifies for 2NF.
All determinants are not Candidate Keys. So, the scheme do not qualify for BCNF .
37 votes -- Rajarshi Sarkar (27.9k points)
3.5.10 Database Normalization: GATE CSE 1997 | Question: 6.9 top☝ ☛ https://gateoverflow.in/2265
Candidate Key is ab.
Since all a,b,c,d are atomic so the relation is in 1 NF.
3.5.11 Database Normalization: GATE CSE 1998 | Question: 1.34 top☝ ☛ https://gateoverflow.in/1671
3NF ,
because we can always have a 3NF decomposition which is dependency preserving and lossless (not possible for any higher
forms).
50 votes -- Digvijay (44.9k points)
Since Book_id is the key we have,
Book_id → Subject_Category_of_book
Book_id → Name_of_Author
Book_id → Nationality_of_Author
If we assume no other FD is there (this is not specified in the question), the relation is in BCNF as the LHS of every FD is
primary key which is also a super key.
a. 2NF
b. New set of FDs are
Book_id → Subject_Category_of_book
Book_id → Name_of_Author
Book_id → Nationality_of_Author
Book_id → Book_title
{Name_of_Author, Book_title} → Nationality_of_Author
{Name_of_Author, Book_title} → Author_address
{Name_of_Author, Book_title} → Book_id
One thing to notice here is only the primary key is being changed from Book_id to {Book_title, Name_of_Author}, but Book_id
is still a key as based on convention Book_id always determines Book_title. Again if we assume no other FD, the relation is in
BCNF as LHS of every FD is a super key. But it is logical to assume the FD
Name_of_Author → Author_address
(won't be valid if two authors have same address and should have been explicit in the question) and this FD is a partial FD on the
candidate key {Name_of_Author, Book_title} as Name_of_Author is a part of the key and Author_address is not a key attribute.
So, this violates 2NF and relation is now just in 1NF. (Debatable if we can assume FDs)
3.5.13 Database Normalization: GATE CSE 1999 | Question: 1.24 top☝ ☛ https://gateoverflow.in/1477
Answer: B
EC is the key for R. Both E and C are not coming on the right hand side of any functional dependency. So, both of them must be
present in any key. Now, with EC and the given FDs, we can derive all other attributes making EC a key.
26 votes -- Rajarshi Sarkar (27.9k points)
3.5.14 Database Normalization: GATE CSE 1999 | Question: 2.7, UGCNET-June2014-III: 25 top☝ ☛ https://gateoverflow.in/1485
R1 ∩ R2 ≠ ϕ. This makes the decomposition lossless join, as all the attributes are keys, R1 ∩ R2 will be a key of the
decomposed relations (lossless condition says the common attribute must be a key in at least one of the decomposed relation).
Now, even the original relation R is in 3NF (even BCNF )as all the attributes are prime attributes (in fact each attribute is a
candidate key). Hence, any decomposition will also be in 3NF (even BCNF ). Option D.
PS: Decomposition in 3NF means decomposed relations are in 3NF . But when we consider any decomposed relation, we must
also include any FD which are being implied by the original relational schema. For example, in a decomposed relation ST U,
there will be a FD U → S as well.
3.5.15 Database Normalization: GATE CSE 2000 | Question: 2.24 top☝ ☛ https://gateoverflow.in/671
(b) is answer.
If A → B then for each same value of A, B value should be same. If all the A values are distinct the FD hold irrespective of the
B values.
Since all Y values are distinct FDs with Y , Y X and Y Z on LHS hold. So, option B is correct.
3.5.16 Database Normalization: GATE CSE 2001 | Question: 2.23 top☝ ☛ https://gateoverflow.in/741
taking up option A first :
We have, R(A, B, C, D) and the Functional Dependency set = {A→B, B→CD}.
Now we will try to decompose it such that the decomposition is a Lossless Join, Dependency Preserving and new relations thus
formed are in BCNF.
We decomposed it to R1(A, B) and R2(B, C, D). This decomposition satisfies all three properties we mentioned prior.
taking up option B :
we have, R(A, B, C, D) and the Functional Dependency set = {A→B, B→C, C→D}.
we decomposed it as R1(A, B), R2(B, C) and R3(C, D). This decomposition too satisfies all properties as decomposition in option
A.
taking up option D :
we have, R(A, B, C, D) and the Functional Dependency set = {A→BCD}.
This set of FDs is equivalent to set = {A→B, A→C, A→D} on applying decomposition rule which is derived from Armstrong's
Axioms.
we decomposed it as R1(A, B), R2(A, C) and R3(A, D). This decomposition also satisfies all properties as required.
taking up option C :
we have, R(A, B, C, D) and the Functional Dependency set = {AB→C, C→AD}.
we decompose it as R1(A, B, C) and R2(C, D). This preserves all dependencies and the join is lossless too, but the relation R1 is
not in BCNF. In R1 we keep ABC together otherwise preserving {AB→C} will fail, but doing so also causes {C→A} to appear
in R1. {C→A} violates the condition for R1 to be in BCNF as C is not a superkey. Condition that all relations formed after
decomposition should be in BCNF is not satisfied here.
We need to identify the INCORRECT, Hence mark option C.
References
(C) is the answer. Because of AB → C and C → A, we cannot have A, B and C together in any BCNF relation- in relation ABC,
C is not a super key and C→ A exists violating BCNF condition. So, we cannot preserve AB → C dependency in any
decomposition of ABCD.
For (A) we can have AB, BCD, A and B the respective keys
For (B) we can have AB, BC, CD, A, B and C the respective keys
For (D) we can have ABCD, A is key
37 votes -- Arjun Suresh (332k points)
3.5.17 Database Normalization: GATE CSE 2002 | Question: 1.19 top☝ ☛ https://gateoverflow.in/824
Answer is A.
References
A. Yes as R1 ∩ R2 = M and M → O
B. NO
From the Dependencies obtained from R1 and R2 , we CANNOT infer NO → P
Mistake That CAN be made: Here we CANNOT apply Pseudo Transitivity Rule using M → O & MN → P to obtain
NO → P because the rule says :if M → O and NO → P then NM → P or MN → P , But here we have M → O
and MN → P ... SO we CANNOT apply the rule here to obtain NO → P from it.
C. BCNF
R1 keys : P, L, MN hence BCNF
R2 key : M hence BCNF
3.5.19 Database Normalization: GATE CSE 2002 | Question: 2.24 top☝ ☛ https://gateoverflow.in/854
A. False . BCNF may or may not satisfy Dependency preservation, 3NF always does. But we can't make any guaranteed
decision, regarding BCNF if it satisfies Dependency preservation
B. False . Both are lossless.
C. True. Using this we can always decide between BCNF & 3NF .
D. False . Every BCNF relation is also 3NF trivially.
A. dependency preservation.
in 3NF Dependency always preserved but in BCNF it may or may not be preserved.
For a particular set of FDs it may not differentiate BCNF and 3NF.
D. 3NF definition also unable to differentiate BCNF & 3NF bcoz every BCNF is trivially 3NF.
C. every 3NF which is not BCNF fails BCNF Definition so it may used to differentiate which is BCNF & which is 3NF ..
25 votes -- Digvijay (44.9k points)
3.5.20 Database Normalization: GATE CSE 2002 | Question: 2.25 top☝ ☛ https://gateoverflow.in/855
Answer is C .
But, we cannot say that A functionally determines B for the entire relation itself. This is because that, A → B holds for this
instance, but in future there might be some tuples added to the instance that may violate A → B.
So, overall on the relation we cannot conclude that A → B, from the relational instance which is just a subset of an entire
relation.
70 votes -- Sourav Roy (2.9k points)
There are three FDs that are valid from the above set of FDs for the given relation :
1. Date_of_Birth → Age
2. Name → Roll_number
3. Roll_number → Name
Candidate keys for the above are : (Date_of_Birth, Name) and (Date_of_Birth, Roll_number)
Clearly there is partial dependency here (Date_of_Birth → Age) and Age is not a prime attribute. So, it is in 1NF only.
Option (D).
Here candidate keys are,
name, courseNo
rollNo, courseNo
That makes name, rollNo, and courseNo prime attributes (part of some candidate key)
If a relation schema is not in 2NF, then for some FD x → y, x should be a proper subset of some candidate key and y should
be a non-prime attribute.
FD s 3 and 4 are not violating 2NF, because the RHS are prime attributes.
For a relation to be in 3NF, for every FD, x → y, x should be a super key or y is a prime attribute. For FD s 3 and
4, LHS are not super keys, but RHS are prime attributes. So, they are not violating 3NF.
For a relation to be in BCNF , for every FD, x → y, x should be super key. This is clearly violated for FD s 3 and 4 and so the
relation scheme is not in BCNF and hence not in 4NF also.
Correct option: B.
3.5.23 Database Normalization: GATE CSE 2005 | Question: 29, UGCNET-June2015-III: 9 top☝ ☛ https://gateoverflow.in/1365
Option C is the only FALSE statement.
We can always have a lossless decomposition into BCNF but not always we can have a lossless and dependency preserving
decomposition. But this is always possible in the case of 3NF.
Option A is true as the requirement of BCNF required a relation schema to be in 3NF. Actually 3NF allows transitive
dependency for prime attributes whereas BCNF does not.
Option D is true as shown below.
1. Either A or B is the candidate key but not both. i.e., A → B or B → A. No other FD is possible and LHS of all FDs are
superkeys and so BCNF requirement is satisfied.
2. Both A and B are candidate keys. i.e., A → B and B → A. Like in above case BCNF requirement is satisfied.
3. Neither A → B nor B → A and so AB is the key. So, no other FD is possible and this case also satisfies BCNF
requirement.
(d) AEH, BEH, DEH
using the given functional dependencies and looking at the dependent attributes, E and H are not dependent on any. So, they must
be part of any candidate key. So, only option is D. If we see the FD's, adding A, B or D to EH do form candidate keys.
34 votes -- Aravind (2.8k points)
{AF}*= {AFDE} .
Hence, option C is wrong.
3.5.26 Database Normalization: GATE CSE 2007 | Question: 62, UGCNET-June2014-II: 47 top☝ ☛ https://gateoverflow.in/1260
Any relation with two attributes is in BCNF ⇒ This is true. It is trivial
A relation in which every key has only one attribute is in 2NF ⇒ This is true. As it is not possible to have Partial Functional
Dependency !
A prime attribute can be transitively dependent on a key in a 3NF relation ⇒ This is true. As For 3NF to be violated we need
something like Key ⇒ Non Key, Non Key ⇒ Non key. 3NF definition says that for functional dependency x → y, either x
should be key or y should be prime attribute. Then we can have something like Key ⇒ Non Key, Non key ⇒ Prime Attribute,
resulting in Transitive FD on Prime Attribute, still in 3NF.
Answer is D.
68 votes -- Akash Kanase (36k points)
Answer: C
It is given that {Author, Title} is the key for both schemas.
The given dependencies are :
{Title, Author} is a candidate key and hence super key also and by definition of BCNF this is in BCNF .
Now, let's see Book (Title, Author, Catalog_no, Publisher, Year , Price):
The non-trivial FDs are
For all these, LHS is a super key and hence BCNF condition is satisfied. But we have some more dependencies here:
' "each supplier and each street within a city has unique name"
This basically means each supplier in a city has unique name making (sname, city) determine sid and hence making it a candidate
key. Each street within a city also has a unique name and so (street, city) is also a candidate key. Even then with all 3 candidate
keys (for Suppliers schema), for any FD, the LHS is a super key here, and hence the relation schema (for other two relations it is
straight forward) is in BCNF .
http://db.grussell.org/section009.html
Correct Answer: A
References
(C) Every relation in BCNF is also in 3NF. Straight from definition of BCNF.
Here, we can see that D is not part of any F D′ s , hence D must be part of the candidate key.
Now D+ ={D}.
Hence, we have to add A, B, C, E, F, G, H to D and check which of them are Candidate keys of size 2.
Here, candidate keys are AD, BD, ED and FD .
Correct Answer: A
42 votes -- Manoj Kumar (26.7k points)
3.5.32 Database Normalization: GATE CSE 2014 Set 1 | Question: 21 top☝ ☛ https://gateoverflow.in/1788
Since E, F, H cannot be derived from anything else E, F, H should be there in key.
Hence, it is key.
Correct Answer: B
41 votes -- Sankaranarayanan P.N (8.5k points)
3.5.33 Database Normalization: GATE CSE 2014 Set 1 | Question: 30 top☝ ☛ https://gateoverflow.in/1797
(A) S1 is TRUE and S2 is FALSE.
The two sets of functional dependencies are not the same. We can not derive AB → E from the 1st set
3.5.34 Database Normalization: GATE CSE 2015 Set 3 | Question: 20 top☝ ☛ https://gateoverflow.in/8420
Option C is correct because {P, S} → {S}
PS: Trivial means something which is always there. An attribute set always determines any of the component attributes and this
is always true irrespective of the relation instance. Hence, this FD becomes trivial.
3.5.35 Database Normalization: GATE CSE 2016 Set 1 | Question: 21 top☝ ☛ https://gateoverflow.in/39637
Any superset of a key is also a superkey from definition of a superkey.
So, answer is B.
' a superkey can be defined as a set of attributes of a relation schema upon which all attributes of the schema are
functionally dependent
References
3.5.36 Database Normalization: GATE CSE 2016 Set 1 | Question: 23 top☝ ☛ https://gateoverflow.in/39646
The actual design is in 1NF coz there are partial dependencies in the given FD set so the original DB design is in 1NF
but not 2NF .
Now, the new design is removing all the partial dependencies so its in 2NF
So, the weakest form that the new schema satisfies that the old one couldn't is 2NF answer is B.
48 votes -- Bharani Viswas (611 points)
3.5.37 Database Normalization: GATE CSE 2017 Set 1 | Question: 16 top☝ ☛ https://gateoverflow.in/118296
In option B and option D there is a dependency W → X which is not implied by the question and hence they are
definitely wrong.
Answer is (B).
email → rollno
Here, email is not a key though but rollno comes under prime-attribute.Hence it's in 3NF but not BCNF.
Y is in BCNF because binary attribute.
Z is not in BCNF because S → Q is in Z and S is not Super key.
Dependency Preserving:
QR → S in Z
R → P is in Y
S → Q is in Z
So it is dependency preserving.
Lossless:
Y ∩ Z = R which is is key of Y .
Lossless it is.
Only 2nd is correct.
In 3NF where functional dependency is of type X → Y
Ans (A): Says X is not a super key but Y is a prime attribute. Satisfies one of the conditions of the 3NF formal definition. As X
is not a Super Key it is not in BCNF .
3.5.41 Database Normalization: GATE CSE 2021 Set 1 | Question: 33 top☝ ☛ https://gateoverflow.in/357418
Decomposition removes redundancy from the database. it is lossless if it’s possible to reconstruct the table from the
given set of decomposition tables using natural join.
Decomposition of a relation R into R1 , R2 is a lossless-join decomposition if at least one of the following functional
dependencies are in F + :
1. ((R1 ∩ R2 ) → (R1 − R2 )) is in F + or
2. ((R1 ∩ R2 ) → (R2 − R1 ) is in F +
3.5.42 Database Normalization: GATE CSE 2021 Set 2 | Question: 40 top☝ ☛ https://gateoverflow.in/357500
Option A: (PS)+ = P, Q, R, S, T so PS → T holds.
Option C: (P )+ = P, Q, R so P → R holds.
It is in 2nf - for 2NF all non prime attribute should be fully functionally dependent on key. Here key is empcode and
contains only one attribute hence no partial dependency. But there is transitive dependency in this (pincode -> city, state). So it is
not in 3NF .
answer: B
51 votes -- Sankaranarayanan P.N (8.5k points)
Answer is A 1NF
Key is {F1 , F2 }
F1 → F3 , F2 → F4 are partial dependencies (a proper subset of candidate key determining a non-key attribute) thus violating
2 NF requirement.
Answer is (B).
Apply membership test for all the given Functional Dependencies.
1. CD → AC
C D+ = CDEAB
As we can see attributes X and Y do not appear in the RHS of any FD and so they need to be part of any
super/candidate key. So, candidate keys are: V XY , WXY , ZXY as these three can determine any other attribute where as a
proper subset of any of them cannot determine all other attributes.
V XZ is not a super key as Y is not there where as V WXY and V WXY Z are super keys but since their proper subsets are also
super keys they are not candidate keys.
Answer is B.
Option A.
(A, B) (B, C) − common attribute is B and due to B → C , B is a key for (B, C) and hence ABC can be losslessly
decomposed into (A, B) and (B, C) .
(A, B, C)(B, D) , common attribute is B and B → D is a FD (via B → C, C → D ), and hence, B is a key for (B, D). So,
decomposition of (A, B, C, D) into (A, B, C)(B, D) is lossless.
The given decomposition is also dependency preserving as the dependencies A → B is present in (A, B), B → C is present in
(B, C), D → B is present in (B, D) and C → D is indirectly present via C → B in (B, C) and B → D in (B, D).
http://www.sztaki.hu/~fodroczi/dbs/dep-pres-own.pdf
References
Answer: D
Here AB is the candidate key and B->G is a partial dependency. So, R is not in 2NF .
41 votes -- Rajarshi Sarkar (27.9k points)
Answer is C.
Here, no common attribute in R1 and R2, therefore lossy join will be there.
and both the dependencies are preserved in composed relations so, dependency preserving.
Let E1 and E2 be two entities in an E/R diagram with simple-valued attributes. R1 and R2 are two relationships between E1
and E2 , where R1 is one-to-many and R2 is many-to-many. R1 and R2 do not have any attributes of their own. What is the
minimum number of tables required to represent this situation in the relational model?
A. 2
B. 3
C. 4
D. 5
Answer ☟
Answer ☟
Answer ☟
Given the basic ER and relational models, which of the following is INCORRECT?
Answer ☟
Consider an Entity-Relationship (ER) model in which entity sets E1 and E2 are connected by an m : n relationship R12 . E1
and E3 are connected by a 1 : n (1 on the side of E1 and n on the side of E3 ) relationship R13 .
E1 has two-singled attributes a11 and a12 of which a11 is the key attribute. E2 has two singled-valued attributes a21 and a22 of
which a21 is the key attribute. E3 has two single-valued attributes a31 and a32 of which a31 is the key attribute. The relationships
do not have any attributes.
If a relational model is derived from the above ER model, then the minimum number of relations that would be generated if all
relation are in 3NF is________________.
Answer ☟
An ER model of a database consists of entity types A and B. These are connected by a relationship R which does not have its
own attribute. Under which one of the following conditions, can the relational table for R be merged with that of A?
Answer ☟
In an Entity-Relationship (ER) model, suppose R is a many-to-one relationship from entity set E1 to entity set E2. Assume
that E1 and E2 participate totally in R and that the cardinality of E1 is greater than the cardinality of E2.
Which one of the following is true about R?
Answer ☟
Which one of the following is used to represent the supporting many-one relationships of a weak entity set in an entity-
relationship diagram?
A. Diamonds with double/bold border
B. Rectangles with double/bold border
C. Ovals with double/bold border
D. Ovals that contain underlined identifiers
Answer ☟
Consider the following entity relationship diagram (ERD) , where two entities E1 and E2 have a relation R of cardinality
1:m.
The attributes of E1 are A11 , A12 and A13 where A11 is the key attribute. The attributes of E2 are A21 , A22 and A23 where
A21 is the key attribute and A23 is a multi-valued attribute. Relation R does not have any attribute. A relational database
containing minimum number of tables with each table satisfying the requirements of the third normal form (3NF ) is designed from
the above ERD . The number of tables in the database is
A. 2
B. 3
C. 5
D. 4
Answer ☟
Consider the entities 'hotel room', and 'person' with a many to many relationship 'lodging' as shown below:
If we wish to store information about the rent payment to be made by person (s) occupying different hotel rooms, then this
information should appear as an attribute of
Answer ☟
Answers: Er Diagram
We need a separate table for many-to-many relation.
one-to-many relation doesn't need a separate table and can be handled using a foreign key.
So, answer is B - 3 tables.
First strong entity types are made to tables. So, we get two tables M and P .
I assume R1 is 1 : 1 or 1 : n as that would minimize the number of tables as asked in question.
Now participation of M in R1 is total (indicated by double arrow) meaning every entity of M participate in R1. Since R1 is not
having an attribute, we can simple add the primary key of P to the table M and add a foreign key reference to M . This handles
R1 and we don't need an extra table. So, M becomes M1, M2, M3, P1 .
N here is a weak entity weakly related to P . So, we form a new table N , and includes the primary key of P(P1) as foreign key
reference. Now (P1, N1) becomes the primary key of N .
Thus we get 3 tables.
M : M1, M2, M3, P1 - M1 primary key, P1 references P
P : P1, P2 − P1 primary key
N : P1, N1, N2 − (P1, N1) primary key, P1 references P .
So, answers is B.
References
First strong entity types are made to tables. So, we get two tables M and P .
I assume R1 is 1 : 1 or 1 : n as that would minimize the number of tables as asked in question.
Now participation of M in R1 is total (indicated by double arrow) meaning every entity of M participate in R1. Since R1 is not
having an attribute, we can simple add the primary key of P to the table M and add a foreign key reference to M . This handles
R1 and we don't need an extra table. So, M becomes {M1, M2, M3, P1} .
P(P1)
(C) is incorrect as a relational table requires that, in a row, an attribute can have exactly one value or NULL value.
Answer is 4. The relations are as shown:
⟨a11 , a12 ⟩ for E1
⟨a21 , a22 ⟩ for E2
⟨a31 , a32 , a11 ⟩ for E3 and E1 − E3 relationship
⟨a11 , a21 ⟩ for m : n relationship E1 − E2
We cannot combine any relation here as it will give rise to partial functional dependency and thus violate 3NF.
Reference: MIT notes
References
The relation table for R should always be merged with the entity that has total participation and relationship should be
many to one.
Answer is C.
Since it is a many to one relationship from E1 to E2, therefore:
Answer : A
We need just two tables for 1NF .
A23 being multi-valued, A21, A23 becomes the key for T 2 as we need to repeat multiple values corresponding to the multi-
valued attribute to make it 1NF . But, this causes partial FD A21 → A22 and makes the table not in 2NF . In order to make the
table in 2NF , we have to create a separate table for multi-valued attribute. Then we get
Here, all determinants of all FDs are keys and hence the relation is in BCNF and so 3NF also. So, we need minimum 3 tables.
Correct Answer: B
98 votes -- Arjun Suresh (332k points)
Since it is many to many, rent cannot be an attribute of room or person entities alone. If depending on number of persons
sharing a room the rent for each person for the room will be different. Otherwise rent can be attribute of room. hence i go for
attribute of Lodging.
Correct Answer: C
47 votes -- Sankaranarayanan P.N (8.5k points)
For secondary key processing which of the following file organizations is preferred? Give a one line justification:
A. Indexed sequential file organization.
B. Two-way linked list.
C. Inverted file organization.
D. Sequential file organization.
Answer ☟
One giga bytes of data are to be organized as an indexed-sequential file with a uniform blocking factor 8. Assuming a block
size of 1 Kilo bytes and a block refrencing pointer size of 32 bits, find out the number of levels of indexing that would be required
and the size of the index at each level. Determine also the size of the master index. The referencing capability (fanout ratio) per
block of index storage may be considered to be 32.
Answer ☟
An ISAM (indexed sequential) file consists of records of size 64 bytes each, including key field of size 14 bytes. An address
of a disk block takes 2 bytes. If the disk block size is 512 bytes and there are 16K records, compute the size of the data and index
areas in terms of number blocks. How many levels of tree do you have for the index?
Answer ☟
Answer ☟
3.7.5 Indexing: GATE CSE 2008 | Question: 16, ISRO2016-60 top☝ ☛ https://gateoverflow.in/414
Answer ☟
Consider a file of 16384 records. Each record is 32 bytes long and its key field is of size 6 bytes . The file is ordered on a
non-key field, and the file organization is unspanned. The file is stored in a file system with block size 1024 bytes , and the size of a
block pointer is 10 bytes . If the secondary index is built on the key field of the file, and a multi-level index scheme is used to store
the secondary index, the number of first-level and second-level blocks in the multi-level index are respectively
A. 8 and 0
B. 128 and 6
C. 256 and 4
D. 512 and 5
Answer ☟
Consider a relational table r with sufficient number of records, having attributes A1 , A2 , … , An and let 1 ≤ p ≤ n . Two
queries Q1 and Q2 are given below.
The database can be configured to do ordered indexing on Ap or hashing on Ap . Which of the following statements is TRUE?
Answer ☟
An index is clustered, if
Answer ☟
A file is organized so that the ordering of the data records is the same as or close to the ordering of data entries in some index.
Than that index is called
A. Dense
B. Sparse
C. Clustered
D. Unclustered
Answer ☟
Consider a database implemented using B+ tree for file indexing and installed on a disk drive with block size of 4 KB . The
size of search key is 12 bytes and the size of tree/disk pointer is 8 bytes. Assume that the database has one million records. Also
assume that no node of the B+ tree and no records are present initially in main memory. Consider that each record fits into one disk
block. The minimum number of disk accesses required to retrieve any record in the database is _______
Answer ☟
A data file consisting of 1, 50, 000 student-records is stored on a hard disk with block size of 4096 bytes. The data file is
sorted on the primary key RollNo . The size of a record pointer for this disk is 7 bytes. Each student-record has a candidate key
attribute called ANum of size 12 bytes. Suppose an index file with records consisting of two fields, ANum value and the record
pointer the corresponding student record, is built and stored on the same disk. Assume that the records of data file and index file are
not split across disk blocks. The number of blocks in the index file is ________
Answer ☟
Answers: Indexing
First we can understand the terms given in the question:
Block size = 1 KB
This is the size of data block (file block containing records) as well as index block (file block containing index entries). Since file
size is given as 1 giga bytes, we get no. of data blocks = 11 GB
KB
= 1 M = 220
The referencing capability (fanout ratio) per block of index storage may be considered to be 32.
This means that an index block can refer to 32 blocks (either data or index blocks). i.e., even though we have 1024 bytes in a
block, and each block pointer size is 4 bytes, it can refer to only 32 blocks. This might be due to large search key size which
must be present for each index entry.
Now, coming to the solution:
No. of entries in first level index (which indexes to the data blocks) (in case of page tables in virtual memory, this will be the
total no. of entries in last level page table) = no. of data blocks (assuming sparse index) = 220
220
No. of index blocks in level 1 = 32 = 215 as each index block can refer to 32 blocks (given fanout) which means size of level 1
index = 215 × 1 KB = 32 MB
215
Since the fanout is 32, no. of index blocks in second level = = 210 .
32
Size of second level index = 210 × 1 KB = 1 MB
10
No. of index blocks in third level = 232 = 32 .
Size of third level index = 32 × 1 KB = 32 KB
32
No. of index blocks in fourth level = 32 = 1 and it occupies 1 KB. Since only 1 index block is there we do not need further
level of indexing.
Searching starts in the last level (this will be level 1 page table in case of virtual memory in OS).
Master Index -- not sure exactly what this means but I assume this is the complete index whose size will be
32 MB + 1 MB + 32 KB + 1 KB = 33.033 MB
Answer: 3
Block size
Blocking factor of record file = Record size
= 512 B/64 B = 8
Block size
Blocking factor of index file = Index entry size
= 512 B/16 B = 32
No. of Records
No. of Blocks needed for data file = Blocking factor of record file
= 16 K/8 = 2 K
No. of first level index entries = No. of Data Blocks needed for data file = 2 K
No. of first level index blocks = ⌈ No. of first level index entries
Blocking factor of index file
⌉ = ⌈ 2K
32 ⌉ = 64
No. of second level index entries = No. of first level index blocks = 64
No. of third level index entries = No. of second level index blocks = 2
No. of third level index blocks = ⌈ No. of third level index entries
Blocking factor of index file
2
⌉ = ⌈ 32 ⌉=1
Indexing will be on Occupation field because Occupation field lexicographically sorted will give the sequence
1, 3, 2, 5, 4 .
Correct Answer: C
71 votes -- Digvijay (44.9k points)
3.7.5 Indexing: GATE CSE 2008 | Question: 16, ISRO2016-60 top☝ ☛ https://gateoverflow.in/414
There are several types of ordered indexes. A primary index is specified on the ordering key field of an ordered file of
records. Recall from Section 17.7 that an ordering key field is used to physically order the file records on disk, and every
record has a unique value for that field. If the ordering field is not a key field- that is, if numerous records in the file can have the
same value for the ordering field— another type of index, called a clustering index, can be used. The data file is called
a clustered file in this latter case. Notice that a file can have at most one physical ordering field, so it can have at most one
primary index or one clustering index, but not both.
Reference -> Database Systems book BY Navathe, 6th Edition, 18.1 Types of Single- Level Ordered Indexes Page no. 632.
Answer should be A.
Content of an index will be <key, block pointer> and so will have size 6 + 10 = 16.
In the first level, there will be an entry for each record of the file. So,total size of first-level index
= 16384 * 16
In the second-level there will be an entry for each block in the first level. So, total number of entries = 256 and total size of
=4
Correct Answer: C
72 votes -- gatecse (63.3k points)
(C) Hashing works well on the 'equal' queries, while ordered indexing works well better on range queries too. For ex
consider B+ Tree, once you have searched a key in B+ tree , you can find range of values via the block pointers pointing to
another block of values on the leaf node level.
Answer is C).
Index can be created using any column or combination of column which need not be unique. So, A, B are not the answers.
Indexed column is used to sort rows of table.Whole data record of file is sorted using index so, C is correct option. (Simple video
explains this).
Video:
Video:
29 votes -- prashant singh (337 points)
Clustered- this is the definition of clustered indexing and for the same reason a table can have only one clustered index.
http://www.ece.rutgers.edu/~yyzhang/spring03/notes/7-B+tree.ppt
Correct Answer: C
References
Since it's a B+ tree, an internal node only has search key values and tree pointers. Let p be the order of an internal node. Hence,
p(8) + (p − 1)(12) ≤ 4096
which gives p ≤ 205.4 .
Therefore p = 205
Now,
Level 3 alone has approximately 8.5 × 106 entries. So we can be sure that a 3-level B+ tree is sufficient to index 106 records.
So to access any record (in the worst case), we need 3 block access to search for the record in the index along with 1 more access
to actually access the record.
Hence, 4 accesses are required.
ANS = 698 .
Index is being built on attribute “ANum” which is Candidate Key, but Given that file is Sorted on Primary Key “Roll No”.
This indicates that The Index must a Secondary Index, (data records not being physically ordered as per the index making a
dense record necessary) so “THERE SHOULD EXIST AN INDEX RECORD FOR EVERY RECORD of Original ‘Student
Table’ ”.
=> Also this Line: “Assume that Records of data file and index file are not split across disc blocks”.
This indicates UNSPANNED STRATEGY.
With This Knowledge, let’s see the Data given.
→ Record Size in Index = 12 + 7 = 19 B (‘ANum’ key size + Record pointer Size), and Block Size = 4096 B
→ So number of Index records in 1 Block = ⌊ 4096
19 ⌋ = 215 records in 1 block (Remember again, unspanned strategy).
where the primary keys are shown underlined. The number of tuples in the student and Enroll tables are 120 and 8 respectively.
What are the maximum and minimum number of tuples that can be present in (Student * Enroll), where ‘*’ denotes natural join?
A. 8, 8
B. 120, 8
960, 8
Answer ☟
How many tuples does the result of the following relational algebra expression contain? Assume that the schema of A ∪ B is the
same as that of A.
(A ∪ B) ⋈A.Id>40∨C.Id<15 C
A. 7
B. 4
C. 5
D. 9
Answer ☟
Consider a join (relation algebra) between relations r(R) and s(S) using the nested loop method. There are 3 buffers each of
size equal to disk block size, out of which one buffer is reserved for intermediate results. Assuming size(r(R)) < size(s(S)), the
join will have fewer number of disk block accesses if
Answer ☟
A database table T1 has 2000 records and occupies 80 disk blocks. Another table T2 has 400 records and occupies 20 disk
blocks. These two tables have to be joined as per a specified join condition that needs to be evaluated for every pair of records from
these two tables. The memory buffer space available can hold exactly one block of records for T1 and one block of records for T2
simultaneously at any point in time. No index is available on either table.
If Nested-loop join algorithm is employed to perform the join, with the most appropriate choice of table to be used in outer loop, the
number of block accesses required for reading the data are
A. 800000
B. 40080
C. 32020
D. 100
Answer ☟
A database table T1 has 2000 records and occupies 80 disk blocks. Another table T2 has 400 records and occupies 20 disk
blocks. These two tables have to be joined as per a specified join condition that needs to be evaluated for every pair of records from
these two tables. The memory buffer space available can hold exactly one block of records for T1 and one block of records for T2
simultaneously at any point in time. No index is available on either table.
If, instead of Nested-loop join, Block nested-loop join is used, again with the most appropriate choice of table in the outer loop, the
reduction in number of block accesses required for reading the data will be
A. 0
B. 30400
C. 38400
D. 798400
Answer ☟
Consider the relations r1 (P, Q, R) and r2 (R, S, T) with primary keys P and R respectively. The relation r1 contains 2000
tuples and r2 contains 2500 tuples. The maximum size of the join r1 ⋈ r2 is :
A. 2000
B. 2500
C. 4500
D. 5000
Answer ☟
Let branch, account and depositor be respectively instances of the above schemas. Assume that account and depositor relations are
much bigger than the branch relation.
Consider the following query:
Пc-name (σb-city = "Agra" ⋀ bal < 0 (branch ⋈ (account ⋈ depositor)
Which one of the following queries is the most efficient version of the above query ?
Answer ☟
Answers: Joins
Rollno in students is key, ans students table has 120 tuples, In Enroll table rollno is FK referencing to Students table. In
natural join it'll return the records where the rollno value of enroll matches with the rollno of students so, in both conditions min
and max records will be resulted (8, 8).
hence A is the answer.
Given relations A, B and C :
B
A
ID Name Age C
ID Name Age
15 Shreya 24 ID Phone Area
12 Arun 60
25 Hari 40 10 2200 02
15 Shreya 24
98 Rohit 20 99 2100 01
99 Rohit 11
99 Rohit 11
To make the query more efficient we can perform the select operation before the cross product.
Now calculate A ∪ B :
ID Name Age
12 Arun 60
15 Shreya 24
25 Hari 40
98 Rohit 20
99 Rohit 11
Please note that union is a set operation and duplicates will not be included by default.
First perform cross-product (A.Id>40 (A ∪ B) × C) , i.e., Multiply each row of A.Id>40 (A ∪ B) with each row of C :
Now perform cross-product ((A ∪ B) ×C.Id<15 C) , i.e., Multiply each row of (A ∪ B) with each row of C.Id<15 C :
We will get:
50. For C.ID = 10, all tuples from A ∪ B satisfies the join condition, hence 5 tuples (union of A and B has only 5 tuples are 2 of
them are repeating for Shreya and Rohit) will be returned. Now, for C.ID = 99, A.ID = 99 and A.ID = 98 (for A.ID = 98, we
need to assume A ∪ B, has the same schema s A as told in the question) satisfies the condition A.ID>40, and hence two tuples
are returned. So, number of tuples = 5 + 2 = 7.
Correct Answer: A
51 votes -- Arjun Suresh (332k points)
In joining B and B using nested loop method, with A in outer loop two factors are involved.
(in worst case all rows of B are matched with all rows of A).
In above ques, |R| < |S|
(i) will be less when number of rows in outer table is less since less no of rows will take less no. of blocks
(ii) if we keep R in outer loop, no. of rows in R are less and no. of blocks in S are more
If we keep S in outer loop, no of rows in S are more and no. of blocks in R are less.
In (ii) block accesses will be multiplication and will come same in both cases.
So, (i) will determine no of block accesses
So, answer is A.
We just have to think which table would be in the outer loop. To minimize block accesses, we have to put that table
outside having fewer records because for each outer record, one block access inside will be required.
Reference: http://en.wikipedia.org/wiki/Nested_loop_join
As per this reference this algorithm will involve nr ∗ bs + br block transfers
T1 can be either R or T2
In Nested loop join for each tuple in first table we scan through all the tuples in second table.
Here we will take table T 2 as the outer table in nested loop join algorithm. The number of block accesses then will be
20 + (400 × 80) = 32020
In block nested loop join we keep 1 block of T 1 in memory and 1 block of T 2 in memory and do join on tuples.
The common attribute is R and it is the primary key in the second relation. So R value should be distinct (primary key
implies unique) for 2500 rows. Hence when we do join, maximum possible number of tuples is 2000.
Correct option is A.
It should be A. As in B we are doing a join between two massive table whereas in A we are doing join between relatively
smaller table and larger one and the output that this inner table gives (which is smaller in comparison to joins that we are doing
in B) is used for join with depositer table with the selection condition.
Options C and D are invalid as there is no b-city column in a-Schema.
Lets see in detail. Let there be 100 different branches. Say about 10% of accounts are below 0. Also, let there be 10, 000
accounts in a branch amounting to 1, 000, 000 total accounts. A customer can have multiple accounts, so let there be on average
2 accounts per customer. So, this amounts to 2, 000, 000 total entries in depositor table. Lets assume these assumptions are true
for all the branches. So, now lets evaluate options A and B.
1. All the accounts in Agra branch, filter by positive balance, and then depositor details of them. So,
Get branch name from branch table after processing 100 records
Filter 10, 000 accounts after processing 1, 000, 000 accounts belonging to Agra
Filter 1000 accounts after processing 10,000 accounts for positive balance
Get 500 depositor details after processing 2, 000, 000 entries for the given 1000 accounts (assuming 1 customer having 2
accounts). So, totally this amounts to 2, 000, 000, 000 record processing.
So totally ≈ 2 billion records needs processing.
2. All the positive balance accounts are found first, and then those in Agra are found.
Filter 100, 000 accounts after processing 1, 000, 000 accounts having positive balance
Find the deposito details of these accounts. So, 100, 000*2, 000, 000 records need processing and this is a much larger
value than for query A. Even if we reduce the percentage of positive balance (10 we assumed) the record processing of
query A will also get reduced by same rate. So, overall query A is much better than query B.
Consider the following implications relating to functional and multivalued dependencies given below, which may or may not
be correct.
i. if A →→ B and A →→ C then A → BC
ii. if A → B and A → C then A →→ BC
iii. if A →→ BC and A → B then A → C
iv. if A → BC and A → B then A →→ C
Answer ☟
a. If A → → B and A → →C then A → BC . So FALSE
b. If A → B and A → C then A→ BC. So A → →BC TRUE..
c. If A → → BC and A → B here B is Subset of AB and (A intersection BC) is phi so
A → B but not A → C so FALSE (Coalescence rule )
d. If A → BC then A → C so A → → C TRUE
if A → B then A → → B holds but reverse not true.
Correct Answer: C
Let r be a relation instance with schema R = (A, B, C, D). We define r1 = πA,B,C (R) and r2 = πA,D (r) . Let s = r1 ∗ r2
where ∗ denotes natural join. Given that the decomposition of r into r1 and r2 is lossy, which one of the following is TRUE?
A. s ⊂ r
B. r ∪ s = r
C. r ⊂ s
D. r ∗ s = s
Answer ☟
The following functional dependencies hold for relations R(A, B, C) and S(B, D, E).
B→A
A→C
The relation R contains 200 tuples and the relation S contains 100 tuples. What is the maximum number of tuples possible in the
natural join R ⋈ S ?
A. 100
B. 200
C. 300
D. 2000
Answer ☟
3.10.3 Natural Join: GATE CSE 2015 Set 2 | Question: 32 top☝ ☛ https://gateoverflow.in/8151
Consider two relations R1 (A, B) with the tuples (1, 5), (3, 7) and R2 (A, C) = (1, 7), (4, 9) . Assume that R(A, B, C) is
the full natural outer join of R1 and R2 . Consider the following tuples of the form (A,B,C):
a = (1, 5, null), b = (1, null, 7), c = (3, null, 9), d = (4, 7, null), e = (1, 5, 7), f = (3, 7, null), g = (4, null, 9).
Which one of the following statements is correct?
A. R contains a, b, e, f, g but not c, d .
B. R contains all a, b, c, d, e, f, g .
C. R contains e, f, g but not a, b .
D. R contains e but not f, g .
Answer ☟
Answer is C r ⊂ s.
s = r1 * r2
r r1 r2 A B C D
A B C D A B C A D 1 2 3 3
1 2 3 3 1 2 3 1 3 1 2 3 4
1 5 3 4 1 5 3 1 4 1 5 3 4
1 5 3 4
(A) 100.
Natural join will combine tuples with same value of the common rows(if there are two common rows then both values must be
equal to get into the resultant set). So by this definition we can get at the max only 100 common values.
3.10.3 Natural Join: GATE CSE 2015 Set 2 | Question: 32 top☝ ☛ https://gateoverflow.in/8151
A B
R1 (A, B) : 1 5
3 7
A C
R2 (A, C) : 1 7
4 9
3.11.1 Referential Integrity: GATE CSE 1997 | Question: 6.10, ISRO2016-54 top☝ ☛ https://gateoverflow.in/2266
Let R(a, b, c) and S(d, e, f) be two relations in which d is the foreign key of S that refers to the primary key of R. Consider
the following four operations R and S
I. Insert into R
II. Insert into S
III. Delete from R
IV. Delete from S
Which of the following can cause violation of the referential integrity constraint above?
A. Both I and IV
B. Both II and III
C. All of these
D. None of these
Answer ☟
The following table has two attributes A and C where A is the primary key and C is the foreign key referencing A with on-
delete cascade.
A C
2 4
3 4
4 3
5 2
7 2
9 5
6 4
The set of all tuples that must be additionally deleted to preserve referential integrity when the tuple (2, 4) is deleted is:
Answer ☟
In table T 1 P is the primary key and Q is the foreign key referencing R in table T 2 with on-delete cascade and on-update cascade.
In table T 2, R is the primary key and S is the foreign key referencing P in table T 1 with on-delete set NULL and on-update
cascade. In order to delete record ⟨3, 8⟩ from the table T 1, the number of additional records that need to be deleted from table T 1 is
_______
Answer ☟
3.11.4 Referential Integrity: GATE CSE 2021 Set 2 | Question: 6 top☝ ☛ https://gateoverflow.in/357534
Consider the following statements S1 and S2 about the relational data model:
Answer ☟
3.11.1 Referential Integrity: GATE CSE 1997 | Question: 6.10, ISRO2016-54 top☝ ☛ https://gateoverflow.in/2266
R S
a (PK) b c d (FK referring to PK of R) e f
1 2
2 1
Correct Answer: B
(C)
(2, 4) (5, 2) (7, 2)
3.11.3 Referential Integrity: GATE CSE 2017 Set 2 | Question: 19 top☝ ☛ https://gateoverflow.in/118236
As Q refers to R so, deleting 8 from Q won't be an issue, however S refers P. But as the relationship given is on delete set
NULL, 3 will be deleted from T1 and the entry in T2 having 3 in column S will be set to NULL. So, no more deletions. Answer
is 0.
3.11.4 Referential Integrity: GATE CSE 2021 Set 2 | Question: 6 top☝ ☛ https://gateoverflow.in/357534
Both S1 and S2 are FALSE.
In a relation scheme multiple foreign attributes can be present referring to primary keys of other relation schemes. A typical
example is an EXAM_RESULTS(sid,eid,marks) scheme where sid and eid are foreign keys referring to the primary keys in
STUDENT and EXAM schemes respectively.
S2 is FALSE because a foreign key can refer to the same scheme (self-referencing foreign key). A typical example is an
EMPLOYEE(eid, mid, …) scheme where mid is the Manager ID referring to the primary key eid of the same scheme.
3 votes -- gatecse (63.3k points)
3.12.1 Relational Algebra: GATE CSE 1992 | Question: 13b top☝ ☛ https://gateoverflow.in/43581
The first indicates the hotels each customer visits, the second tells which snacks each hotel serves and last indicates which snacks
are liked by each customer. Express the following query in relational algebra:
Print the hotels the serve the snack that customer Rama likes.
Answer ☟
The underlined attributes indicate the primary keys for the relations. The ‘year’ attribute for the STUDENTS relation indicates the
year in which the student is currently studying (First year, Second year etc.)
A. Write a relational algebra query to print the roll number of students who have registered for cno 322.
B. Write a SQL query to print the age and year of the youngest student in each year.
3.12.3 Relational Algebra: GATE CSE 1994 | Question: 3.8 top☝ ☛ https://gateoverflow.in/2494
Give a relational algebra expression using only the minimum number of operators from (∪, −) which is equivalent to R ∩ S.
Answer ☟
Express the following queries using (one or more of) SELECT, PROJECT, JOIN and DIVIDE operations.
Answer ☟
Explain in one English sentence, what each of the following relational algebra queries is designed to determine
Answer ☟
3.12.6 Relational Algebra: GATE CSE 1997 | Question: 76-a top☝ ☛ https://gateoverflow.in/19838
EMP contains information about employees. PROJ about projects and involved about which employees involved in which projects.
The underlined attributes are the primary keys for the respective relations.
What is the relational algebra expression containing one or more of {σ, π, ×, ρ, −} which is equivalent to SQL query.
select eno from EMP|INVOLVED where EMP.eno=INVOLVED.eno and INVOLVED.pno=3
Answer ☟
Given two union compatible relations R1 (A, B) and R2 (C, D), what is the result of the operation R1 ⋈A=C∧B=D R2 ?
A. R1 ∪ R2
B. R1 × R2
C. R1 – R2
D. R1 ∩ R2
Answer ☟
COURSES gives the number and name of all the available courses.
PRE_REQ gives the information about which courses are pre-requisites for a given course.
COMPLETED indicates what courses have been completed by students
Express the following using relational algebra:
List all the courses for which a student with Student_no 2310 has completed all the pre-requisites.
Answer ☟
3.12.9 Relational Algebra: GATE CSE 1999 | Question: 1.18, ISRO2016-53 top☝ ☛ https://gateoverflow.in/1471
Consider the join of a relation R with a relation S . If R has m tuples and S has n tuples then the maximum and minimum
sizes of the join respectively are
A. m + n and 0
B. mn and 0
C. m + n and |m − n|
D. mn and m + n
Answer ☟
3.12.10 Relational Algebra: GATE CSE 2000 | Question: 1.23, ISRO2016-57 top☝ ☛ https://gateoverflow.in/647
Which of the following queries cannot be expressed using the basic relational algebra operations (σ, π, ×, ⋈, ∪, ∩, −) ?
Answer ☟
Suppose the adjacency relation of vertices in a graph is represented in a table Adj (X, Y ). Which of the following queries
cannot be expressed by a relational algebra expression of constant length?
Answer ☟
3.12.12 Relational Algebra: GATE CSE 2001 | Question: 1.25 top☝ ☛ https://gateoverflow.in/718
Let r and s be two relations over the relation schemes R and S respectively, and let A be an attribute in R. The relational
algebra expression σA=a (r ⋈ s) is always equal to
A. σA=a (r)
B. r
C. σA=a (r) ⋈ s
D. None of the above
Answer ☟
A university placement center maintains a relational database of companies that interview students on campus and make job
offers to those successful in the interview. The schema of the database is given below:
COMPANY(−cname
−−−−, clocation) STUDENT(−
srollno
−−−−−, sname, sdegree)
INTERVIEW(cname, srollno , idate) OFFER(cname, srollno , osalary)
−−−−−−−−−−− −−−−−−−−−−−
The COMPANY relation gives the name and location of the company. The STUDENT relation gives the student’s roll number,
name and the degree program for which the student is registered in the university. The INTERVIEW relation gives the date on
which a student is interviewed by a company. The OFFER relation gives the salary offered to a student who is successful in a
company’s interview. The key for each relation is indicated by the underlined attributes
a. Write a relational algebra expressions (using only the operators ⋈, σ, π, ∪, − ) for the following queries.
i. List the rollnumbers and names of students who attended at least one interview but did not receive any job offer.
ii. List the rollnumbers and names of students who went for interviews and received job offers from every company
with which they interviewed.
b. Write an SQL query to list, for each degree program in which more than five students were offered jobs, the name of the
degree and the average offered salary of students in this degree program.
Answer ☟
p ( 1 ⋈ 2 ⋈⋯⋈ m)
Answer ☟
Consider the relation Student (name, sex, marks), where the primary key is shown underlined, pertaining to students in a class
that has at least one boy and one girl. What does the following relational algebra expression produce? (Note: ρ is the rename
operator).
πname{σsex=female (Student)} − πname(Student ⋈(sex=female∧x=male∧marks≤m) ρn,x,m (Student))
Answer ☟
Answer ☟
I. ΠP (R ⋈ S)
II. ΠP (R) ⋈ ΠP (S)
III. ΠP (ΠP,Q (R) ∩ ΠP,Q (S))
IV. ΠP (ΠP,Q (R) − (ΠP,Q (R) − ΠP,Q (S)))
A. Only I and II
B. Only I and III
C. Only I, II and III
D. Only I, III and IV
Suppose R1 (− −, B) and R2 (−
A −, D) are two relation schemas. Let r1 and r2 be the corresponding relation instances. B is a
C
foreign key that refers to C in R2 . If data in r1 and r2 satisfy referential integrity constraints, which of the following is ALWAYS
TRUE?
A. ∏B (r1 ) − ∏C (r2 ) = ∅
B. ∏C (r2 ) − ∏B (r1 ) = ∅
C. ∏B (r1 ) = ∏C (r2 )
D. ∏B (r1 ) − ∏C (r2 ) ≠ ∅
Answer ☟
3.12.19 Relational Algebra: GATE CSE 2014 Set 3 | Question: 21 top☝ ☛ https://gateoverflow.in/2055
What is the optimized version of the relation algebra expression πA1 (πA2 (σF1 (σF2 (r)))) , where A1, A2 are sets of attributes
in r with A1 ⊂ A2 and F1, F2 are Boolean expressions based on the attributes in r ?
Answer ☟
3.12.20 Relational Algebra: GATE CSE 2014 Set 3 | Question: 30 top☝ ☛ https://gateoverflow.in/2064
Consider the relational schema given below, where eId of the relation dependent is 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:
ΠempId (employee) − ΠempId (employee ⋈(empId=eID)∧(empAge≤depAge) dependent)
The above query evaluates to the set of empIds of employees whose age is greater than that of
A. some dependent.
B. all dependents.
C. some of his/her dependents.
D. all of his/her dependents.
Answer ☟
3.12.21 Relational Algebra: GATE CSE 2015 Set 1 | Question: 7 top☝ ☛ https://gateoverflow.in/8094
3.12.22 Relational Algebra: GATE CSE 2017 Set 1 | Question: 46 top☝ ☛ https://gateoverflow.in/118329
Consider a database that has the relation schema CR(StudentName, CourseName). An instance of the schema CR is as given
below.
StudentName CourseName
SA CA
SA CB
SA CC
SB CB
SB CC
SC CA
SC CB
SC CC
SD CA
SD CB
SD CC
SD CD
SE CD
SE CA
SE CB
SF CA
SF CB
SF CC
Answer ☟
Consider the relations r(A, B) and s(B, C) , where s. B is a primary key and r. B is a foreign key referencing s. B. Consider
the query
Q : r ⋈ (σB<5 (s))
Let LOJ denote the natural left outer-join operation. Assume that r and s contain no null values.
Which of the following is NOT equivalent to Q?
A. σB<5 (r ⋈ s)
B. σB<5 (r LOJ s)
C. r LOJ (σB<5 (s))
D. σB<5 (r) LOJ s
Answer ☟
Table: Q
How many tuples will be returned by the following relational algebra query?
Answer: ________
Answer ☟
3.12.25 Relational Algebra: GATE CSE 2021 Set 1 | Question: 27 top☝ ☛ https://gateoverflow.in/357424
The following relation records the age of 500 employees of a company, where empNo (indicating the employee number) is
the key:
empAge(empNo , age)
−−−−−−
Consider the following relational algebra expression:
Answer ☟
A table 'student' with schema (roll, name, hostel, marks), and another table 'hobby' with schema (roll, hobbyname) contains
records as shown below:
Table: hobby
Roll Hobby Name
Table: student
1798 chess
Roll Name Hostel Marks
1798 music
1798 Manoj Rathor 7 95
2154 music
2154 Soumic Banerjee 5 68
2369 swimming
2369 Gumma Reddy 7 86
2581 cricket
2581 Pradeep pendse 6 92
2643 chess
2643 Suhas Kulkarni 5 78
2643 hockey
2711 Nitin Kadam 8 72
2711 volleyball
2872 Kiran Vora 5 92
2872 football
2926 Manoj Kunkalikar 5 94
2926 cricket
2959 Hemant Karkhanis 7 88
2959 photography
3125 Rajesh Doshi 5 82
3125 music
3125 chess
Relations S and H with the same schema as those of these two tables respectively contain the same information as tuples. A new
relation S ′ is obtained by the following relational algebra operation:
The difference between the number of rows output by the SQL statement and the number of tuples in S ′ is
A. 6
B. 4
C. 2
D. 0
Answer ☟
3.12.1 Relational Algebra: GATE CSE 1992 | Question: 13b top☝ ☛ https://gateoverflow.in/43581
OPTIMIZED ANSWER
A. πrollno (σcno. =322 (REGISTERED_FOR))
B. SELECT year, min(age) FROM STUDENTS GROUP BY year
In the second question we have to find the year and youngest student from that year. So, we have to apply MIN aggregate
function on each year (group by year).
3.12.3 Relational Algebra: GATE CSE 1994 | Question: 3.8 top☝ ☛ https://gateoverflow.in/2494
R − (R − S)
There is no need to use Union operator here.
Just because they say you can use operators from (∪, −) we don't need to use both of them.
Also they are saying that only the minimum number of operators from (∪, −) which is equivalent to R ∩ S .
My expression is Minimal.
A. πpname(publishers)
a. Select the (user# and) titles of the books issued to User# 6
b. Select author names of the books issued to users whose home town is Delhi
3.12.6 Relational Algebra: GATE CSE 1997 | Question: 76-a top☝ ☛ https://gateoverflow.in/19838
πeno (σEMP.eno=INVOLVED.eno∧INVOLVED.pno=3 (EMP × INVOLVED))
23 votes -- Prashant Singh (47.2k points)
3.12.7 Relational Algebra: GATE CSE 1998 | Question: 1.33 top☝ ☛ https://gateoverflow.in/1670
This question is an example of Theta Join,
r ⋈θ s = σθ (r × s)
The join here will be selecting only those tuples where A = C and B = D, meaning it is the intersection. D option.
T1 will have all the available course numbers
T2 will have all the course numbers completed by student2310
T3 will have the combination of all the courses and the courses completed by student2310
PRE_REQ − T3 (set minus operation) will return us all the entries of PRE_REQ which are not there in T3 ,
Suppose ⟨C1 , C5 ⟩ is a particular tuple of (PRE-REQ − T3 ),
Now what does it imply? ⟹ It implies that C5 is one of the prerequisite course for C1 which has not been completed by C5 .
Proof: If student2310 would have completed C5 then definitely ⟨C1 , C5 ⟩ should have been there in T3 (remember T3 is
the combination of all the courses and the courses completed by student2310) and in that case (PRE_REQ − T3 ) can not have
⟨C1 , C5 ⟩ as a tuple.
So, for any such ⟨C1 , C5 ⟩ tuple, (⟨C1 , any course id ⟩) of PRE_REQ − T3 , C1 should not be printed as output (Since there is
some prerequisite course for C1 which student2310 has not completed).
Now, suppose we have not got any tuple as a result of (PRE_REQ − T3 ) where C2 is there under cno attribute (⟨C2 , any
course id⟩), what does it imply? ⟹ It implies that student2310 has completed all the prerequisite courses C2 .
Hence, in order to get the final result we need to project cno from (PRE_REQ − T3 ) and subtract it from T1 .
T1 ← πcno (COURSES)
T2 ← ρT2 (std2310completedcourses) (πcno (σstudent_no=2310 (COMPLETED)))
T3 ← T1 × T2
T4 ← ρT4 (cno, pre_cno) (PRE_REQ − T3 )
Result ← T1 − πcno (T4 )
3.12.9 Relational Algebra: GATE CSE 1999 | Question: 1.18, ISRO2016-53 top☝ ☛ https://gateoverflow.in/1471
Answer is B.
mn
Case 1: if there is a common attribute between R and S , and every row of r matches with the each row of s- i.e., it means, the
0 There is a common attribute between R and S and nothing matches- the join attribute in r and s have no common value.
3.12.10 Relational Algebra: GATE CSE 2000 | Question: 1.23, ISRO2016-57 top☝ ☛ https://gateoverflow.in/647
Possible solutions, relational algebra:
(a) Join relation using attribute dpart_no.
(b)
(c) We cannot generate relational algebra of aggregate functions using basic operations. We need extended operations here.
Option (c).
3.12.11 Relational Algebra: GATE CSE 2001 | Question: 1.24 top☝ ☛ https://gateoverflow.in/717
The answer is D.
Answer: D.
3.12.12 Relational Algebra: GATE CSE 2001 | Question: 1.25 top☝ ☛ https://gateoverflow.in/718
Answer is C.
C is just the better form of query, more execution friendly because requires less memory while joining. query, given in question
takes more time and memory while joining.
a) Part i) :
1
2
3
minus
1
2
equals to
You got the required student's roll numbers but to print their names, store that in Temp and join with Student table.
∏ scrollno,sname ( Temp ⋈ Student)
a) Part ii) : Those who got interviewed (includes those who got jobs in all,some,none)
Now interviewed - offer = those who did not get jobs or got in some.
B 2
A 3
Now again subtract whatever you got from all students of the interview again
1
2
3
minus
2
3
equals to
But note that it is not an intersection. You may think.... A-(A-B) so intersection.
But it is not... We are doing A-B on all tuples.
But the next subtraction is done on a particular attribute. (It became distinct since we focused on it only)
∏scrollno (Interview) - ∏scrollno( Interview - Offer)
You got the required student's roll numbers but to print their names, store that in Temp and join with Student table.
∏ scrollno,sname ( Temp ⋈ Student)
b) select s.sdegree,AVG(o.osalary) from Student s,Offer o where s.srollno=o.srollno having count(distinct s.srollno)>5 group by
select distinct in SQL is equivalent to project and by default relation 1, relation 2 in SQL corresponds to cross-product.
So, option A.
40 votes -- Arjun Suresh (332k points)
OPTION : (D)
The given query states the following conditions:
Sex = F∧
x = M∧ → (1)
Marks ≤ m
Selecting the tuple (row#6 from the above table), which satisfies the condition (1) and PROJECTING Πname ⟹ S2
S1
Πname(σsex=F (Student)) =
S2
Hence, the query:
S1
– S2 = S1
S2
Let us take another relation data of Student(Name, Sex, Marks)
S2
⟹ Female students who scored less than equal to some Male students.
S4
S2
Πname[σsex=F (Student)] =
S4
Hence, the result of the query will be:
S2 S2
− = {}
S4 S4
From the above relational data of table Student(Name, Sex, Marks)
(D) is the correct option
In short,
{≥ All boys} =∣ universal ∣ − ∣< some M∣
{> All boys} =∣ universal ∣ − ∣≤ some M∣
{≥ some boys} =∣ universal ∣ − ∣< all M∣
ENROLL
2 C1
2 C1
2 C2
⟹ ∗ =
3 C1
3 C2
3 C2
⟹ 3 C1
⟹ C1
Ans is b,
First it does a cross join between female students id and all course ids, then subtract the entries which are already present in
enroll table.
Remaining are the courseids which are NOT done by at least one female student
(d) i, iii, iv
iv) is the expansion for natural join represented with other operators.
R : {⟨‘‘1 ", ‘‘abc ", ‘‘p1 ", ‘‘p2 ", ‘‘p3 "⟩ , ⟨‘‘2 ", ‘‘xyz ", ‘‘p1 ", ‘‘p2 ", ‘‘p3 "⟩}
S : {⟨‘‘1 ", ‘‘abc ", ‘‘q1 ", ‘‘q2 "⟩ ⟨‘‘2 ", ‘‘def ", ‘‘q1 ", ‘‘q2 "⟩}
i. R ⋈ S gives
{⟨‘‘1 ", ‘‘abc ", ‘‘p1 ", ‘‘p2 ", ‘‘p3 ", ‘‘q1 ", ‘‘q2 "⟩}
{⟨‘‘1 ", ‘‘abc "⟩ , ⟨‘‘2 ", ‘‘xyz "⟩} ∩ {⟨‘‘1 ", ‘‘abc "⟩ , ⟨‘‘2 ", ‘‘def "⟩} = {⟨‘‘1 ", ‘‘abc "⟩}
{⟨‘‘1 ", ‘‘abc "⟩ , ⟨‘‘2 ", ‘‘xyz "⟩} − ({⟨‘‘1 ", ‘‘abc "⟩ , ⟨‘‘2 ", ‘‘xyz "⟩} − {⟨‘‘1 ", ‘‘abc "⟩ , ⟨‘‘2 ", ‘‘def "⟩})
= {⟨‘‘1 ", ‘‘abc "⟩ , ⟨‘‘2 ", ‘‘xyz "⟩} − {⟨‘‘2 ", ‘‘xyz "⟩} = {⟨‘‘1 ", ‘‘abc "⟩}
Answer is A.
Referential integrity means, all the values in foreign key should be present in primary key.
3.12.19 Relational Algebra: GATE CSE 2014 Set 3 | Question: 21 top☝ ☛ https://gateoverflow.in/2055
(A) πA1 (σF1∧F2 (r))
since A1 is subset of A2 will get only A1 attributes as it is in the outside, so we can remove project A2.
Two Selects with boolean expression can be combined into one select with And of two boolean expressions.
38 votes -- Aravind (2.8k points)
3.12.20 Relational Algebra: GATE CSE 2014 Set 3 | Question: 30 top☝ ☛ https://gateoverflow.in/2064
(D) all of his/her dependents.
The inner query selects the employees whose age is less than or equal to at least one of his dependents. So, subtracting from the
set of employees, gives employees whose age is greater than all of his dependents.
3.12.21 Relational Algebra: GATE CSE 2015 Set 1 | Question: 7 top☝ ☛ https://gateoverflow.in/8094
Option D is correct because SELECT operation in SQL is equivalent to The projection operation in relational algebra,
except that SELECT in SQL retains duplicates but projection gives only distinct.
3.12.22 Relational Algebra: GATE CSE 2017 Set 1 | Question: 46 top☝ ☛ https://gateoverflow.in/118329
ANS) 4
1. CA
T1 WILL GIVE :- 2. CB
3. CC
Option a, b, d will restrict all record with B<5 but option C will include record with b >= 5 also, so false.
C is answer.
R ⋅ V = V 2 , there are two tuples which have Y parameter as Y 3 and Y 2.
P ⋅ Y = R ⋅ Y , there are no coincide with Y 3, and there is one tuple coincide with Y 2 which have X parameter as X2 .
Q ⋅ T > 2 , there are two tuples which have Y parameter as Y 1 and Y 2 which have X parameter as X1
Number of Tuples = 1
26 votes -- Shaik Masthan (50.4k points)
3.12.25 Relational Algebra: GATE CSE 2021 Set 1 | Question: 27 top☝ ☛ https://gateoverflow.in/357424
Correct Answer: C
Whenever a Database Problem intimidating like the above one(maybe it’s just me) appears, it’s often worth to Dissect the
statements for Individual components and build up your arguments from there rather than attempting it head-on by some random
example/argument only to get swayed by your hidden biases and choose the wrong answer.
Now,
2. We take the cross product of both the relations, each tuple in A(unmodified relation empAge) will be combined with every
tuple in B(renamed relation empAge).
3. We filter the tuples according to the condition age > age1 which implies those tuples whose age values in A that are
4. We find out the set of unique empNo by using Projection(Π)(Note: empNo derived from LHS side of ⋈ the original
relation A that we were talking about).
Since the empNo is derived from relation A(LHS) whose age attribute is greater than the relation’s minimum implies
employees from A are selected whose age isn’t the minimum hence, Option C is true.
Also, if empNo1 was chosen instead of empNo then it would list all the employee numbers whose age isn’t the maximum.
SQL query will return:
Roll Hostel
2369 7
2581 6
2643 5
2643 5
Duplicate Row is present
in Hobby table
2872 5
2926 5
2959 7
The following relations are used to store data about students, courses, enrollment of students in courses and teachers of
courses. Attributes for primary key in each relation are marked by ‘*’.
Students (rollno*, sname, saddr)
courses (cno*, cname)
enroll(rollno*, cno*, grade)
teach(tno*, tname, cao*)
(cno is course number cname is course name, tno is teacher number, tname is teacher name, sname is student name, etc.)
Write a SQL query for retrieving roll number and name of students who got A grade in at least one course taught by teacher names
Ramesh for the above relational database.
Answer ☟
The following relations are used to store data about students, courses, enrollment of students in courses and teachers of
courses. Attributes for primary key in each relation are marked by ‘*’.
(cno is course number, cname is course name, tno is teacher number, tname is teacher name, sname is student name, etc.)
For the relational database given above, the following functional dependencies hold:
Answer ☟
3.13.3 Relational Calculus: GATE CSE 1998 | Question: 2.19 top☝ ☛ https://gateoverflow.in/1692
Which of the following query transformations (i.e., replacing the l.h.s. expression by the r.h.s expression) is incorrect? R 1 and
R2 are relations, C1 and C2 are selection conditions and A1 and A2 are attributes of R1.
A. σC1 (σC2 (R1 )) → σC2 (σC1 (R1 ))
B. σC1 (πA1 (R1 )) → πA1 (σC1 (R1 ))
C. σC1 (R1 ∪ R2 ) → σC1 (R1 ) ∪ σC1 (R2 )
D. πA1 (σC1 (R1 )) → σC1 (πA1 (R1 ))
Answer ☟
3.13.4 Relational Calculus: GATE CSE 1999 | Question: 1.19 top☝ ☛ https://gateoverflow.in/1472
The relational algebra expression equivalent to the following tuple calculus expression:
{t ∣ t ∈ r ∧ (t[A] = 10 ∧ t[B] = 20)} is
A. σ(A=10∨B=20) (r)
Answer ☟
3.13.5 Relational Calculus: GATE CSE 2001 | Question: 2.24 top☝ ☛ https://gateoverflow.in/742
Answer ☟
With regards to the expressive power of the formal relational query languages, which of the following statements is true?
Answer ☟
Let R1 (− −, B, C) and R2 (−
A −, E) be two relation schema, where the primary keys are shown underlined, and let C be a
D
foreign key in R1 referring to R2 . Suppose there is no violation of the above referential integrity constraint in the corresponding
relation instances r1 and r2 . Which of the following relational algebra expressions would necessarily produce an empty relation?
A. ΠD (r2 ) − ΠC (r1 )
B. ΠC (r1 ) − ΠD (r2 )
C. ΠD (r1 ⋈C≠D r2 )
D. ΠC (r1 ⋈C=D r2 )
Answer ☟
Consider the relation employee(name, sex, supervisorName) with name as the key, supervisorName gives the name of the
supervisor of the employee under consideration. What does the following Tuple Relational Calculus query produce?
{e. name ∣ employee(e) ∧ (∀x) [¬employee (x) ∨ x. supervisorName ≠ e. name ∨ x. sex = ‘‘male "]}
Answer ☟
Which of the following tuple relational calculus expression(s) is/are equivalent to ∀t ∈ r (P (t)) ?
I. ¬∃t ∈ r (P (t))
II. ∃t ∉ r (P (t))
III. ¬∃t ∈ r (¬P (t))
IV. ∃t ∉ r (¬P (t))
A. I only
B. II only
C. III only
D. III and IV only
Answer ☟
Let R and S be relational schemes such that R = {a, b, c} and S = {c}. Now consider the following queries on the database:
4. Select R.a,R.b
From R,S
Where R.c = S.c
Answer ☟
Answer ☟
Which of the following relational query languages have the same expressive power?
I. Relational algebra
II. Tuple relational calculus restricted to safe expressions
III. Domain relational calculus restricted to safe expressions
Answer ☟
Consider a selection of the form σA≤100 (r), where r is a relation with 1000 tuples. Assume that the attribute values for A
among the tuples are uniformly distributed in the interval [0, 500]. Which one of the following options is the best estimate of the
number of tuples returned by the given selection query ?
A. 50
B. 100
C. 150
D. 200
Answer ☟
Answer ☟
Where enroll.grade='A' AND enroll.cno in (select cno from teach where tname='Ramesh')
In table teach we have Primary Key (which is automatically a candidate key as well) as (tno, coa). We have the
functional dependency tno → tname which is a partial functional dependency (a proper subset of candidate key determining a
non-key attribute) which violates 2NF requirement and hence 3NF too. So the relational database is not in 3NF.
To make it in 3NF we have to break teach table into (tno*, coa*) and (tno*, tname).
9 votes -- Tarun kushwaha (1.7k points)
3.13.3 Relational Calculus: GATE CSE 1998 | Question: 2.19 top☝ ☛ https://gateoverflow.in/1692
D) if the selection condition is on attribute A2, then we cannot replace it by RHS as there will not be any attribute A2
due to projection of A1 only.
3.13.4 Relational Calculus: GATE CSE 1999 | Question: 1.19 top☝ ☛ https://gateoverflow.in/1472
Answer: (C)
Tuple t should have two attributes A and B such that t. A = 10 and t. B = 20.
So, (Tuples having A = 10)∩( Tuples having B = 20) =( Tuples having A = 10 and B = 20).
3.13.5 Relational Calculus: GATE CSE 2001 | Question: 2.24 top☝ ☛ https://gateoverflow.in/742
Answer: C.
It returns tuples not belonging to R1 (which is infinitely many). So, it is not safe.
Reference: http://nptel.ac.in/courses/IIT-MADRAS/Intro_to_Database_Systems_Design/pdf/3.1_Tuple_Relational_Calculus.pdf
References
3.13.6 Relational Calculus: GATE CSE 2002 | Question: 1.20 top☝ ☛ https://gateoverflow.in/825
Answer: C
Relational algebra has the same power as safe relational calculus as:
A query can be formulated in safe Relational Calculus if and only if it can be formulated in Relational Algebra.
Answer is (B).
C in R1 is a foreign key referring to the primary key D in R2. So, every element of C must come from some D element.
OR (∨) is commutative and associative, therefore i can rewrite given query as:
{e. name ∣ employee(e) ∧ (∀x) [¬employee (x) ∨ x. sex = ‘‘male " ∨x. supervisorName ≠ e. name]}
{e. name ∣ employee(e) ∧ (∀x) [¬(employee (x) ∧ x. sex ≠ ‘‘male ") ∨ x. supervisorName ≠ e. name]}
{e. name ∣ employee(e) ∧ (∀x) [(employee (x) ∧ x. sex ≠ ‘‘male ") ⇒ x. supervisorName ≠ e. name]}
{e. name ∣ employee(e) ∧ (∀x) [(employee (x) ∧ x. sex = ‘‘female ") ⇒ x. supervisorName ≠ e. name]}
It is clear now they are saying something about female employees, This query does not say anything about male employees.
Means retrieves those e.name, who is not a supervisor of any female employees.
i.e it retrieves name of employees with no female subordinate.
(here "immediate" is obvious, as we are checking first level supervisor.)
Hence, option C.
185 votes -- Sachin Mittal (15.8k points)
Only III is correct.
The given statement means for all tuples from r, P is true. III means there does not exist a tuple in r where P is not true. Both are
equivalent.
IV is not correct as it as saying that there exist a tuple, not in r for which P is not true, which is not what the given expression
means.
43 votes -- Arjun Suresh (332k points)
1. πR−S (r) − πR−S (πR−S (r) × s − πR−S,S (r))
= πa,b (r) − πa,b (πa,b (r) × s − πR (r))
= (r/s)
2. Expanding logically the statement means to select t(a, b) from r such that for all tuples u in s, there is a tuple v in r, such
that u = v[S] and t = v[R − S]. This is just equivalent to (r/s)
3. Expanding logically the statement means that select t(a, b) from r such that for all tuples v in r, there is a tuple u in s,
such that u = v[S] and t = v[R − S]. This is equivalent to saying to select (a, b) values from r, where the c value is in
some tuple of s.
4. This selects (a, b) from all tuples from r which has an equivalent c value in s.
http://pages.cs.wisc.edu/~dbbook/openAccess/firstEdition/slides/pdfslides/mod3l1.pdf
Correct Answer: A
References
Answer: A
Four queries given in SQL, RA, TRC and DRC in four statements respectively retrieve the required information.
36 votes -- Rajarshi Sarkar (27.9k points)
Answer: D
σA≤100 (r)
r has 1000 tuples
Values for A among the tuples are uniformly distributed in the interval [0, 500]. This can be split to 5 mutually exclusive (non-
overlapping) and exhaustive (no other intervals) intervals of same width of 100
([0 − 100], [101 − 200], [201 − 300], [301 − 400], [401 − 500], 0 makes the first interval larger - this must be a typo in
question) and we can assume all of them have same number of values due to Uniform distribution. So, number of tuples with A
value in first interval should be
Correct Answer: D
35 votes -- Abhinav Rana (723 points)
t ∣ ∃E ∈ Enrolment t = E. school-id
Returns school-ids from Enrolment table SUCH THAT
Since to pass an exam > 35 mark is needed, this means selecting the school-ids where the pass percentage of students across all
the exams taken together is > 35.
Correct Answer: C.
3.14.1 Safe Query: GATE CSE 2017 Set 1 | Question: 41 top☝ ☛ https://gateoverflow.in/118324
Consider a database that has the relation schemas EMP(EmpId, EmpName, DeptId), and DEPT(DeptName, DeptId). Note that
the DeptId can be permitted to be NULL in the relation EMP. Consider the following queries on the database expressed in tuple
relational calculus.
Answer ☟
3.14.1 Safe Query: GATE CSE 2017 Set 1 | Question: 41 top☝ ☛ https://gateoverflow.in/118324
Answer is (D)
before ∧ operation all three expressions are the same,
i.e.return true if for each tuple t we have finite no of tuple u in employee table for which they have same employee_name.
(I) but in 2nd part, for each tuple v in department there may exist infinite no of tuple t for which they may not be equal.
i.e. true for finite no of tuples ∧ true for infinite no of tuples, over all true for finite tuple.
(ii) there may exist infinite no of tuple for which at least one tuple v belongs to department table for which they may not be
equal.
i.e. true for finite no of tuples ∧ true for infinite no of tuples, over all true for finite tuple.
(iii) this one actually true for finite no of tuples, as there may exist only finite tuple which may be equal to at least one tuple v in
department. bcz department table contain finite no of tuple all tuple t which are same may not be more than all tuple v in
department table in case of equality operation.
i.e. true for finite ∧ true for finite tuple, over all true for finite tuple.
so all TRC query will return finite tuple which implies all are safe.
reference:http://www.cs.sfu.ca/CourseCentral/354/zaiane/material/notes/Chapter3/node14.html
http://people.cs.pitt.edu/~chang/156/10calculus.html
http://www.cs.princeton.edu/courses/archive/fall13/cos597D/notes/relational_calc.pdf
References
Describe the relational algebraic expression giving the relation returned by the following SQL query.
Select SNAME
from S
Where SNOin
(select SNO
from SP
where PNOin
(select PNO
from P
Where COLOUR='BLUE'))
Select SNAME
from S
Where SNOin
(select SNO
from SP
where PNOin
(select PNO
from P
Where COLOUR='BLUE'))
What relations are being used in the above SQL query? Given at least two attributes of each of these relations.
Answer ☟
The queries regarding data in the above database are formulated below in SQL. Describe in ENGLISH sentences the two queries
that have been posted:
i. SELECT ename
FROM employees
WHERE eno IN
(SELECT eno
FROM working
GROUP BY eno
HAVING COUNT(*)=
(SELECT COUNT(*)
FROM projects))
Answer ☟
PART (PCODE,PNAME,PDESC,CITY).
PROJECTS (PRCODE,PRNAME,PRCITY).
SPPR (SCODE,PCODE,PRCODE,QTY).
i. Get SCODE values for suppliers who supply to both projects PR1 and PR2.
ii. Get PRCODE values for projects supplied by at least one supplier not in the same city.
Answer ☟
i. Print PCODE values for parts supplied to any project in DEHLI by a supplier in DELHI.
ii. Print all triples <CITY, PCODE, CITY> such that a supplier in first city supplies the specified part to a project in the second
city, but do not print the triples in which the two CITY values are same.
Answer ☟
EMP contains information about employees. PROJ about projects and involved about which employees involved in which projects.
The underlined attributes are the primary keys for the respective relations.
State in English (in not more than 15 words)
What the following relational algebra expressions are designed to determine
(Note: ρE(EMP) conceptually makes a copy of EMP and names it E (ρ is called the rename operator))
Answer ☟
(Assume that each student likes at least one ice-cream and frequents at least one parlor)
Express the following in SQL:
Print the students that frequent at least one parlor that serves some ice-cream that they like.
Answer ☟
Answer ☟
a. Find all employees names who work in departments located at ‘Calcutta’ and whose salary is greater than Rs.50,000.
b. Calculate, for each department number, the number of employees with a salary greater than Rs. 1,00,000.
Answer ☟
Answer ☟
Answer ☟
In SQL, relations can contain null values, and comparisons with null values are treated as unknown. Suppose all comparisons
with a null value are treated as false. Which of the following pairs is not equivalent?
A. x = 5 not(not(x = 5))
B. x = 5 x > 4 and x < 6, where x is an integer
C. x ≠ 5 not(x = 5)
D. none of the above
Answer ☟
Consider a relation geq which represents "greater than or equal to", that is, (x, y) ∈ geq only if y ≥ x .
create table geq
(
ib integer not null,
ub integer not null,
primary key ib,
foreign key (ub) references geq on delete cascade
);
Answer ☟
Consider a relation examinee (regno, name, score), where regno is the primary key to score is a real number.
Write a relational algebra using (Π, σ, ρ, ×) to find the list of names which appear more than once in examinee.
Answer ☟
Consider a relation examinee (regno, name, score), where regno is the primary key to score is a real number.
Write an SQL query to list the regno of examinees who have a score greater than the average score.
Answer ☟
Consider a relation examinee (regno, name, score), where regno is the primary key to score is a real number.
appears (regno, centr_code)
Answer ☟
Consider the set of relations shown below and the SQL query that follows.
Students: (Roll_number, Name, Date_of_birth)
Courses: (Course_number, Course_name, Instructor)
Grades: (Roll_number, Course_number, Grade)
Select distinct Name
from Students, Courses, Grades
where Students.Roll_number=Grades.Roll_number
and Courses.Instructor = 'Korth'
and Courses.Course_number = Grades.Course_number
and Grades.Grade = 'A'
A. Names of students who have got an A grade in all courses taught by Korth
B. Names of students who have got an A grade in all courses
C. Names of students who have got an A grade in at least one of the courses taught by Korth
D. None of the above
Answer ☟
A. the average salary is more than the average salary in the company
B. the average salary of male employees is more than the average salary of all male employees in the company
C. the average salary of male employees is more than the average salary of employees in same the department
D. the average salary of male employees is more than the average salary in the company
Answer ☟
3.15.20 Sql: GATE CSE 2005 | Question: 77, ISRO2016-55 top☝ ☛ https://gateoverflow.in/1400
The relation book (title,price) contains the titles and prices of different books. Assuming that no two books have the same
price, what does the following SQL query list?
select title
from book as B
where (select count(*)
from book as T
Answer ☟
Consider the relation account (customer, balance) where the customer is a primary key and there are no null values. We would
like to rank customers according to decreasing balance. The customer with the largest balance gets rank 1. Ties are not broke but
ranks are skipped: if exactly two customers have the largest balance they each get rank 1 and rank 2 is not assigned.
Query1:
select A.customer, count(B.customer)
from account A, account B
where A.balance <=B.balance
group by A.customer
Query2:
select A.customer, 1+count(B.customer)
from account A, account B
where A.balance < B.balance
group by A.customer
1. Query1 will produce the same row set as Query2 for some but not all databases.
2. Both Query1 and Query 2 are a correct implementation of the specification
3. Query1 is a correct implementation of the specification but Query 2 is not
4. Neither Query1 nor Query2 is a correct implementation of the specification
5. Assigning rank with a pure relational query takes less time than scanning in decreasing balance order assigning ranks using
ODBC.
Answer ☟
Consider the relation enrolled (student, course) in which (student, course) is the primary key, and the relation paid (student,
amount) where student is the primary key. Assume no null values and no foreign keys or integrity constraints.
Given the following four queries:
Query1:
select student from enrolled where student in (select student from paid)
Query2:
select student from paid where student in (select student from enrolled)
Query3:
select E.student from enrolled E, paid P where E.student = P.student
Query4:
select student from paid where exists
(select * from enrolled where enrolled.student = paid.student)
Answer ☟
Consider the relation enrolled (student, course) in which (student, course) is the primary key, and the relation paid (student,
amount) where student is the primary key. Assume no null values and no foreign keys or integrity constraints. Assume that amounts
6000, 7000, 8000, 9000 and 10000 were each paid by 20% of the students. Consider these query plans (Plan 1 on left, Plan 2 on
right) to “list all courses taken by students who have paid more than x”
A disk seek takes 4ms, disk data transfer bandwidth is 300 MB/s and checking a tuple to see if amount is greater than x takes
10µs. Which of the following statements is correct?
A. Plan 1 and Plan 2 will not output identical row sets for all databases
B. A course may be listed more than once in the output of Plan 1 for some databases
C. For x = 5000, Plan 1 executes faster than Plan 2 for all databases
D. For x = 9000, Plan I executes slower than Plan 2 for all databases
Answer ☟
Consider the table employee(empId, name, department, salary) and the two queries Q1 , Q2 below. Assuming that department
5 has more than one employee, and we want to find the employees who get higher salary than anyone in the department 5, which
one of the statements is TRUE for any arbitrary employee table?
Select e.empId
From employee e
Q1 : Where not exists
(Select * From employee s Where s.department = "5" and s.salary >= e.salary)
Answer ☟
Assume that relations corresponding to the above schema are not empty. Which one of the following is the correct interpretation of
the above query?
A. Find the names of all suppliers who have supplied a non-blue part.
B. Find the names of all suppliers who have not supplied a non-blue part.
C. Find the names of all suppliers who have supplied only non-blue part.
D. Find the names of all suppliers who have not supplied only blue parts.
Answer ☟
A. 1, 0
B. 1, 2
C. 1, 3
D. 1, 5
Answer ☟
Consider a database table T containing two columns X and Y each of type integer . After the creation of the table, one record
(X=1, Y=1) is inserted in the table.
Let MX and MY denote the respective maximum values of X and Y among all records in the table at any point in time. Using MX
and MY, new records are inserted in the table 128 times with X and Y values being MX+1, 2*MY+1 respectively. It may be
noted that each time after the insertion, values of MX and MY change.
What will be the output of the following SQL query after the steps mentioned above are carried out?
SELECT Y FROM T WHERE X=7;
A. 127
B. 255
C. 129
D. 257
Answer ☟
A. 3
B. 9
C. 5
D. 6
Answer ☟
Answer ☟
B
A
C
Id Name Age
Id Name Age
15 Shreya 24 Id Phone Area
12 Arun 60
25 Hari 40 10 2200 02
15 Shreya 24
98 Rohit 20 99 2100 01
99 Rohit 11
99 Rohit 11
How many tuples does the result of the following SQL query contain?
SELECT A.Id
FROM A
WHERE A.Age > ALL (SELECT B.Age
FROM B
WHERE B.Name = ‘Arun’)
A. 4
B. 3
C. 0
D. 1
Answer ☟
Answer ☟
Answer ☟
SQL allows duplicate tuples in relations, and correspondingly defines the multiplicity of tuples in the result of joins. Which
one of the following queries always gives the same answer as the nested query shown below:
select * from R where a in (select S.a from S)
Answer ☟
A. Names of all the employees with at least one of their customers having a ‘GOOD’ rating.
B. Names of all the employees with at most one of their customers having a 'GOOD' rating.
C. Names of all the employees with none of their customers having a 'GOOD' rating.
D. Names of all the employees with all their customers having a 'GOOD' rating.
Answer ☟
Performance
Student
Roll_No Course Marks
−−−−−−−− −−−−−−−
1 Math 80
Roll_No Student_Name
−−−−−−−− 1 English 70
1 Raj
2 Math 75
2 Rohit
3 English 80
3 Raj
2 Physics 65
3 Math 80
The numbers of rows that will be returned by the SQL query is_________________.
Answer ☟
such that it always finds the addresses of theaters with maximum capacity?
Answer ☟
Answer ☟
Consider a database that has the relation schema EMP (EmpId, EmpName, and DeptName). An instance of the schema EMP
and a SQL query on it are given below:
EMP
SELECT AVG(EC.Num)
FROM EC
WHERE (DeptName, Num) IN
(SELECT DeptName, COUNT(EmpId) AS
EC(DeptName, Num)
FROM EMP
GROUP BY DeptName)
Answer ☟
top_scorer
Answer ☟
Query 2:
SELECT B.isbn, S.copies FROM Book B LEFT OUTER JOIN Stock S ON B.isbn=S.isbn;
Query 3:
SELECT B.isbn, S,copies FROM Book B RIGHT OUTER JOIN Stock S ON B.isbn=S.isbn
Query 4:
SELECT B.isbn, S.copies FROM Book B FULL OUTER JOIN Stock S ON B.isbn=S.isbn
Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries?
A. Query 1
B. Query 2
C. Query 3
D. Query 4
Answer ☟
A relational database contains two tables Student and Performance as shown below:
Table: Performance
The primary key of the Student table is Roll_no. For the performance table, the columns Roll_no. and Subject_code together form
the primary key. Consider the SQL query given below:
SELECT S.Student_name, sum(P.Marks)
FROM Student S, Performance P
WHERE P.Marks >84
GROUP BY S.Student_name;
Answer ☟
The primary key of each table is indicated by underlining the constituent fields.
SELECT s.sno, s.sname
FROM Suppliers s, Catalogue c
WHERE s.sno=c.sno AND
cost > (SELECT AVG (cost)
FROM Catalogue
WHERE pno = ‘P4’
GROUP BY pno) ;
Answer ☟
A relation r(A, B) in a relational database has 1200 tuples. The attribute A has integer values ranging from 6 to 20, and the
attribute B has integer values ranging from 1 to 20. Assume that the attributes A and B are independently distributed.
The relation scheme given below is used to store information about the employees of a company, where empId is the key and
deptId indicates the department to which the employee is assigned. Each employee is assigned to exactly one department.
The above query gives, for each department in the company, the number of female employees whose salary is greater than the
average salary of
A. employees in the department
B. employees in the company
C. female employees in the department
D. female employees in the company
Answer ☟
A relational database contains two tables student and department in which student table has columns roll_no, name and
dept_id and department table has columns dept_id and dept_name. The following insert statements were executed successfully to
populate the empty tables:
Insert into department values (1, 'Mathematics')
Insert into department values (2, 'Physics')
Insert into student values (l, 'Navin', 1)
Insert into student values (2, 'Mukesh', 2)
Insert into student values (3, 'Gita', 1)
How many rows and columns will be retrieved by the following SQL statement?
Select * from student, department
Answer ☟
The following sequence of SQL statements was successfully executed on table T1.
Update T1 set marks = marks + 5
Select avg(marks) from T1
18.75
Answer ☟
Consider two tables in a relational database with columns and rows as follows:
Table: Student
Table: Department
Roll_no Name Dept_id
Dept_id Dept_name
1 ABC 1
1 A
2 DEF 1
2 B
3 GHI 2
3 C
4 JKL 3
Roll_no is the primary key of the Student table, Dept_id is the primary key of the Department table and Student.Dept_id is a foreign
key from Department.Dept_id
What will happen if we try to execute the following two SQL statements?
Answer ☟
In an inventory management system implemented at a trading corporation, there are several tables designed to hold all the
information. Amongst these, the following two tables hold information on which items are supplied by which suppliers, and which
warehouse keeps which items along with the stock-level of these items.
Supply = (supplierid, itemcode)
Inventory = (itemcode, warehouse, stocklevel)
For a specific information required by the management, following SQL query has been written
Select distinct STMP.supplierid
From Supply as STMP
Where not unique (Select ITMP.supplierid
From Inventory, Supply as ITMP
Where STMP.supplierid = ITMP.supplierid
And ITMP.itemcode = Inventory.itemcode
And Inventory.warehouse = 'Nagpur');
For the warehouse at Nagpur, this query will find all suppliers who
A. do not supply any item
B. supply exactly one item
C. supply one or more items
D. supply two or more items
Answer ☟
Consider a database with three relation instances shown below. The primary keys for the Drivers and Cars relation are did and
C: Cars relation
A. Karthikeyan, Boris
B. Sachin, Salman
C. Karthikeyan, Boris, Sachin
D. Schumacher, Senna
Answer ☟
Consider a database with three relation instances shown below. The primary keys for the Drivers and Cars relation are did and
cid respectively and the records are stored in ascending order of these primary keys as given in the tables. No indexing is available
in the database.
C: Cars relation
Cid Cname colour
101 Renault blue
102 Renault red
103 Ferrari green
104 Jaguar red
select D.dname
from Drivers D
where D.did in (
select R.did
from Cars C, Reserves R
where R.cid = C.cid and C.colour = 'red'
intersect
select R.did
from Cars C, Reserves R
where R.cid = C.cid and C.colour = 'green'
)
Let n be the number of comparisons performed when the above SQL query is optimally executed. If linear search is used to locate a
tuple in a relation using primary key, then n lies in the range:
A. 36 − 40
B. 44 − 48
C. 60 − 64
D. 100 − 104
Answer ☟
A. for each school with more than 200 students appearing in exams, the name of the school and the number of 100s scored by its
students
B. for each school with more than 200 students in it, the name of the school and the number of 100s scored by its students
C. for each school with more than 200 students in it, the name of the school and the number of its students scoring 100 in at least
one exam
D. nothing; the query has a syntax error
Answer ☟
Answers: Sql
There are 3 relations here:
S(SNAME, SNO)
SP(SNO, PNO)
P(PNO, COLOUR)
1.SELECT ename
FROM employees
WHERE eno IN
(SELECT eno
FROM working
GROUP BY eno
HAVING COUNT (*)=
(SELECT COUNT (*)
FROM projects));
SCODE values for suppliers who supply to both projects PR1 and PR2 -
PRCODE values for projects supplied by at least one supplier not in the same city -
* is natural join.
8 votes -- Ashish verma (7.2k points)
i. Print PCODE values for parts supplied to any project in DELHI by a supplier in DELHI
Select SP.PCODE
From SPPR SP, Projects PR, Supplier SU
Where SP.PRcode = PR.PRcode
and SU.Scode = SP.Scode
and PR.PRcity = "DELHI"
and SU.city = "DELHI";
i. Πeno (INV OLV ED) −Πeno ((Πeno (INV OLV ED) × Πpno (PROJ) − INV OLV ED)
Πeno (INV OLV ED)− All employees involved in projects → (A)
Πeno ((Πeno (INV OLV ED) × Πpno (PROJ) − INV OLV ED)− gives all employee who are not involved in at
least one project. → (B)
A − B = employee No. of employees involved on the all project. (Division Operator)
SELECT DISTINCT A.student FROM
FREQUENTS A, SERVES B, LIKES C
WHERE
A.parlor=B.parlor
AND
B.ice-cream=C.ice-cream
AND
A.student=C.student;
OR
SELECT DISTINCT A.student FROM FREQUENTS A
WHERE
parlor IN
(SELECT parlor FROM SERVES B
WHERE B.ice-cream IN
(SELECT ice-cream
FROM LIKES C
WHERE C.student = A.student));
(D)
SQL wont remove duplicates like relational algebra projection, we have to remove it explicitly by distinct.
If there are no indexes on the relation SQL will either chose one/more on its own or simply work without any index. No index
would just slow the query but it will surely work.
(a)
select Employee-name
from EMP, DEPT
where Salary>50000 and EMP.Dept-no=DEPT.Dept-no and Location="Calcutta"
(b)
select Dept-no, count(*)
from EMP where salary > 100000
group by Dept-no
This question is about SQL, in SQL Relations are MULTISET, not SET. So, R or S can have duplicated.
Answer: A.
A. If R has duplicates, in that case, due to distinct keyword those duplicates will be eliminated in final result. So, R can not have
duplicates. If S is empty RXS becomes empty, so S must be non empty. This is true.
C. Same argument as B.
D. Assume that R has duplicates. Then Distinct keyword will remove duplicates. So, result of query ! = R , so This is false.
Answer is option C.
a.
Create view TP(T1.acctno, T1.date, T2.amount)
as (Select T1.acctno, T1.date, T2.amount
from Transaction T1, Transaction T2
where T1.acctno = T2.acctno
and T2.date <= T1.date);
b.
i.
Create view V(acctno, date, balance)
as (select acctno, date, sum(amount)
from TP
group by acctno, date);
ii.
select acctno, min(balance)
from V
group by acctno;
Answer: C
The table can be depicted as:
ib(PK) ub(FK)
z w=u
u v=x
x y
v ≤ y ( as v = x)
u < v ≤ y, u! = v ( as v = x and ib is the Primary Key)
w < v ≤ y ( as w = u)
z < w < v ≤ y, z! = w ( as w = u and ib is the Primary Key)
πexm1.name (σ(exm1.regno≠examinee.regno)∧(emp1.name=emp2.name) )(ρexm1 (examinee) × examinee)
16 votes -- Tauhin Gangwar (6.7k points)
There are many ways to write a query, all of which will perform the same task. One way is:
SELECT regno
FROM examinee
WHERE score > (SELECT AVG(score)
FROM examinee )
Here, the inner query is returning the average of the scores. And outer query selects those regno that have a score greater than
this average.
C. Names of the students who have got an A grade in at least one of the courses taught by Korth.
31 votes -- Arjun Suresh (332k points)
D is the answer.
The inner query is over all department and over both male and female employees while the outer query is only for male
employees.
28 votes -- Arjun Suresh (332k points)
3.15.20 Sql: GATE CSE 2005 | Question: 77, ISRO2016-55 top☝ ☛ https://gateoverflow.in/1400
Answer: D
The outer query selects all titles from book table. For every selected book, the subquery returns count of those books which are
more expensive than the selected book. The where clause of outer query will be true for 5 most expensive book. For example
count (*) will be 0 for the most expensive book and count(*) will be 1 for second most expensive book.
78 votes -- Rajarshi Sarkar (27.9k points)
Both Query1 and Query2 are not correct implementations because: Assume that we have a table with n customers having
the same balance. In that case Query1 will give rank n to each customer. But according to the question the rank assigned should
be 1. And Query2 will return an empty result set ( as it will never return rank 1). So statement 4 is correct. For the same reason
Query1 is wrong though it is true if we assume the relation set is empty. Statements 2 and 3 are false as 4 is TRUE. Statement 5
is false as a single scan should be faster than a join query. So, the best option should be C, though 1 is not technically correct.
Query1 and Query3 : output will be the same
and Query2 and Query4 : output will be same
I have run these queries on the online compiler, this what i get
BEGIN TRANSACTION;
COMMIT;
/* output */
Query 1:
1
1
3
3
Query 2:
1
3
Query 3:
1
1
3
3
Query 4:
1
3
In all cases plan 1 is faster than plan 2 cause in plan 1 we are reducing the load by doing select amount > x and then the loop
But, in case of plan 2 its in the nested loop so it need to check every time and will take more time to execute .
Answer: A
Create a table like this:
create table employee(empId int(50), name varchar(50), department int(50), salary int(50));
insert into employee values (1, 'a', 4, 90);
insert into employee values (2, 'b', 5, 30);
insert into employee values (3, 'c', 5, 50);
insert into employee values (4, 'd', 5, 80);
insert into employee values (8, 'f', 7, 10);
Q2 returns empId of those employees who get salary more than the minimum salary offered in department 5. It returns 1, 3, 4 for
the above table. See here: http://sqlfiddle.com/#!9/9acce/2
According the question the answer should be 1 for the above table.
PS: The question implies that the required employee must not be from department 5.
References
SELECT P.pid FROM Parts P WHERE P.color<>’blue’
SELECT S.sname
FROM Suppliers S
WHERE S.sid NOT IN
(C) 1, 3
X = 2, Y = 2 × 1 + 1 = 3
X = 3, Y = 2 × 3 + 1 = 7
X = 4, Y = 2 × 7 + 1 = 15
X = 5, Y = 2 × 15 + 1 = 31
X = 6, Y = 2 × 31 + 1 = 63
X = 7, Y = 2 × 63 + 1 = 127
Correct Answer: A
41 votes -- Arjun Suresh (332k points)
The answer is (C).
When we perform the natural join on S and T then result will be like this
After that count (*) will count total tuples present in this table so here it is 5.
41 votes -- neha pawar (3.3k points)
GATE 2012 Answer key is (C) Q and R are true.
But correct answer should be B.
"A grouped table is a set of groups derived during the evaluation of a <group by clause> or a <having clause>. A group is a
multiset of rows in which all values of the grouping column or columns are equal if a <group by clause> is specified, or the
group is the entire table if no <group by clause> is specified. A grouped table may be considered as a collection of tables. Set
functions may operate on the individual tables within the grouped table."
The above link says that all columns used in group by must be present in select clause as per SQL-92 standard but later standards
doesn't enforce it. I tried this on MySQL and it works. It is allowed in MSSQL also- see below link.
' Expressions in the GROUP BY clause can contain columns of the tables, derived tables or views in the FROM
clause. The columns are not required to appear in the SELECT clause <select> list. Each table or view column in any
nonaggregate expression in the <select> list must be included in the GROUP BY list:
<cond> ALL evaluates to TRUE if inner query returns no tuples. So, Number of tuples returned will be number of tuples
in A = 3 .
Reference: http://dcx.sap.com/1200/en/dbusage/all-test-quantified-subquery.html
Correct Answer: B
References
(D)Both are false
S1: Foreign key constraint means a lot of constraints it has to be a primary key(which intrun has few constraints)
Alternate reason: Using a check condition we can have the same effect as Foreign key while adding elements to the child table.
But when we delete an element from the parent table the referential integrity constraint is no longer valid. So, a check constraint
cannot replace a foreign key.
So, we cannot replace it with a single check.
S2: if a and b forms a primary key in R, a alone cannot form a foreign key. i.e. R(a,b,c) and S( a,d,e ) a of S references to a of R
but a of R is not candidate key but a prime attribute since a,b combine a key.
Foreign key definition: it should be a candidate key in some other table(in our case it is only a prime attribute).
SELECT dept-id, MAX(hire-date)
FROM employees JOIN departments USING(dept-id)
WHERE location-id =1700
GROUP BY dept-id
This inner query will give the max hire date of each department whose location_id =1700
and outer query will give the last name and hire-date of all those employees who joined on max hire date.
answer should come to (B) no errors.
And we can use group by and where together, who said we can not :(
C)
Consider the following instances of R and S
R S
A B C A X Z
1 2 3 1 2 3
1 2 3 3 5 7
7 8 9 7 6 5
7 8 9 7 6 5
A B C
1 2 3
1 2 3
7 8 9
7 8 9
For Option,
A) since multiplicity of tuples is disturbed
select R.* from R, S where R.a=S.a
∴ Output will be
A B C
1 2 3
1 2 3
7 8 9
7 8 9
7 8 9
7 8 9
B)
select distinct R.* from R,S where R.a=S.a
A B C
1 2 3
7 8 9
C) ANSWER
select R.* from R,(select distinct a from S) as S1 where R.a=S1.a
Multiplicity of tuples is maintained. ∵ Multiplicity of duplicate tuples will be distributed when there is a match between R.a and
S.a and for that match S.a’s value is repeated.
So, Output will be
So, an employee whose ALL customers gives him GOOD rating is chosen;
All such employees are chosen.
Answer = option D
For answering there is no need to execute the query, we can directly answer this as 2
How?
It means all name that are same should be kept in one row.
There are 3 names. But in that there is a duplicate with Raj being repeated ⟹ Raj produces one row and Rohit produces one
row ⟹ Total 2 rows.
2nd statement which is executed from the query is Where Clause : Where S.Roll_no = P.Roll_no
⟹ delete those rows which does not satisfy the WHERE condition. Then the result will be
3rd statement which is executed from the query is Group by Clause : Group by S.Student_Name
⟹ Merge those rows which are having same name, then result will be
Note that, this can't be used as final result as it violates 1NF (multiple values in each tuple for S.Roll_no, P.Roll_no, P.Course
and P.marks)
4th statement which is executed from the query is Select Clause : Select S.Student_Name, SUM(P.marks)
⟹ Delete un-necessary columns and calculate the aggregate functions, then result will be
S.Student_name P.marks
Raj 310
Rohit 140
A is the answer
1st query will return the following:
Table Name : Total (name, capacity)
name capacity
Ajmer 20
Bikaner 40
Churu 30
Dungargarh 10
3rd query will be final and it's tuples will be considered as output, where name of district and its total capacity should be more
than or equal to 25
name
Bikaner
Churu
The inner query will return
DeptName Num
AA 4
AB 3
AC 3
AD 2
AE 1
Now AVG(EC.Num) will find the average of Num values in the above-returned query, which is
(4 + 3 + 3 + 2 + 1) ÷ 5 = 2.6
ALL (EMPTY SET) always returns TRUE. So first where condition is always satisfied.
Second where condition will return all those rows who have more goals than ANY German player. Since, minimum goals by a
German is 10, all the rows which are greater than 10 Goals will be returned.
I.e. first 7 rows in the table.
Hence, answer: 7.
Answer is D.
Since the full-outer join is nothing but a combination of inner-join and the remaining tuples of both the tables that couldn't satisfy
the common attributes' equality condition, and merging them with "null" values.
20 votes -- Baljit kaur (1k points)
Group by Student_name ⟹ number of distinct values of Student_name
in the instance of the relation all rows have distinct name then it should results 5 tuples !
27 votes -- Shaik Masthan (50.4k points)
The given query is a nested subquery but not co-related subquery (inner query is independent of the outer and so can be
executed independently)
SELECT AVG (cost) FROM Catalogue WHERE pno= 'P4' GROUP BY pno
sno
− pno −
−− − cost
−−− −−−
S1 P1 150
S1 P2 50
S1 P3 100
S2 P4 200
S2 P5 250
S3 P1 250
S3 P2 150
S3 P5 300
S3 P4 250
First, we will select the tuples with pno = ‘P4’ and then group by pno (so just one group) and then find the average cost.
sno
− pno −
−− − cost
−−− −−−
S2 P4 200
S3 P4 250
200+250
So average cost = 2 = 225
∴ the inner query will return 225
So here we need to do cross product of supplier table s and Catalogue table c and from the cross product we will select those
rows where s. sno = c. sno AND cost > 225
Since it is given that cost > 225 so we do not need to consider rows from the Catalogue table having cost ≤ 225 while doing
cross product. Hence from the Catalogue table only the row numbers 5, 6, 8, 9 need to be taken while doing the cross product.
After doing cross product we’ll get,
Now after doing cross product only 4 tuples will be selected from the table due to the condition s. sno = c. sno
P(A > 10) = 10 2
15 = 3
1
P(B = 18) = 20
2 1 1
P(A > 10 ∧ B = 18) = 3 × 20 = 30
P(A > 10 ∨ B = 18) = P(A > 10) + P(B = 18)– P(A > 10 ∧ B = 18)
2 1 1 40+3–2 41
= 3 + 20 – 30 = 60 = 60
41
Estimated number of tuples = 60 × 1200 = 820
The above answer is TRUE for SQL SELECT but not for Relational Algebra as by theory relational algebra operates on a set
which means all the elements must be distinct. Since we have 15 distinct possible values for A and 20 distinct possible values for
B, in strict relational algebra we’ll get
41
Estimated number of tuples = 60 × (15 × 20) = 205.
Official Answer: 205 OR 820.
It’s a nested query but not Co-related query.
Evaluate the innermost query first.
select avg(salary)
from emp
Since, there is no specific joining condition specified, it will retrieve Cartesian product of the table
Answer: D.
52 votes -- Sankaranarayanan P.N (8.5k points)
Update on null gives null. Now, avg function ignores null values. So, here avg will be (15 + 25 + 35)/3 = 25.
http://msdn.microsoft.com/en-us/library/ms177677.aspx
Correct Answer: C
References
Answer is C
Here in (i) when we update in STUDENT table Dept_id = NULL it is fine as a foreign key can be NULL.
But in (ii) if we set in DEPARTMENT table dept id = NULL it is not possible as PRIMARY KEY cannot be NULL.
Instead of update to NULL, if we try DELETE, then also it is not allowed as we have foreign key reference to it from STUDENT
table with Dept_id = 1. DELETE ON CASCADE clause is a way to avoid this issue which will delete all referenced entries from
the child table too but unless told we cannot assume this as this cause is not universally applicable.
40 votes -- neha pawar (3.3k points)
Answer is D) supply two or more items
The whole query returns the distinct list of suppliers who supply two or more items.
32 votes -- Bran Stark (339 points)
For color = "Red", did = {22, 22, 31, 31, 64}
Intersection of Red and Green will give did = {22, 31} which is Karthikeyan and Boris
Answer: A
34 votes -- Vikrant Singh (11.2k points)
select D.dname
from Drivers D
where D.did in (
select R.did
from Cars C, Reserves R
where R.cid = C.cid and C.colour = 'red'
intersect
select R.did
from Cars C, Reserves R
where R.cid = C.cid and C.colour = 'green'
)
select R.did from Cars C, Reserves R where R.cid = C.cid and C.colour = 'red'
So, first, get 2 red cars by scanning 4 tuples of the cars relation. Now, for each of the two 'red' cars, we scan all the 10 tuples of
the 'Reserves' relation and thus we get 2 × 10 + 4 = 24 comparisons. But this is not optimal. We can check in the reverse order
for each tuple of the 'Reserves' relation because 'cid' is a primary key (hence unique) of 'Cars' relation.
Supposing our earlier selection is ⟨102, 104⟩ then this requires 3 + 7 × 2 = 17 comparisons. due to if
(R.cid == 102||R.cid == 104)
If the order was ⟨104, 102⟩ , then 2 + 8 × 2 = 18 comparisons. due to if (R.cid == 104||R.cid == 102)
Thus, totally 21 to 22 comparisons and gives ⟨22, 31, 64⟩ as did.
Similarly for the 'green' car we get 4 + 10 = 14 comparisons. due to if (R.cid == 103) and gives ⟨22, 31, 74⟩ as did.
Intersect requires 1 + 2 + 3 = 6 comparisons in the best case and 3 + 2 + 3 = 8 in the worst case and this gives ⟨22, 31⟩ .
Finally, we have to locate the did 22 and did 31 from the driver table and did is the primary key. As told in the question, we use
linear search and for 22, we hit on the first try, and for 31 we hit on the third try. So, 1 + 3 = 4 comparisons.
Thus total no. of comparisons = (21 to 22) + 14 + (6 to 8) + 4 = 45 to 48.
Correct Answer: B.
D:
If Select clause consist aggregate and non - aggregate columns.All non aggregate columns in the Select clause must appear in
Group By clause. But in this query Group by clause consists school-id instead of school-name
http://weblogs.sqlteam.com/jeffs/archive/2007/07/20/but-why-must-that-column-be-contained-in-an-aggregate.aspx
References
3.16.1 Timestamp Ordering: GATE CSE 2017 Set 1 | Question: 42 top☝ ☛ https://gateoverflow.in/118325
In a database system, unique timestamps are assigned to each transaction using Lamport's logical clock. Let T S(T1 ) and
T S(T2 ) be the timestamps of transactions T1 and T2 respectively. Besides, T1 holds a lock on the resource R, and T2 has requested
a conflicting lock on the same resource R. The following algorithm is used to prevent deadlocks in the database system assuming
that a killed transaction is restarted with the same timestamp.
T1 is killed
else T2 waits.
Answer ☟
3.16.1 Timestamp Ordering: GATE CSE 2017 Set 1 | Question: 42 top☝ ☛ https://gateoverflow.in/118325
' In a database system, unique timestamps are assigned to each transaction using Lamport's logical clock
Since Unique Timestamps are assigned, so there is no question of two transaction having same timestamp.
Moreover, there is nothing mentioned about the size of the counter by which it can be determined that whether there will be case
of timestamp wrap around or not.
So, there will be no timestamp wrap around.
In Lamport's logical clock Timestamps are assigned in increasing order of enumeration.
So, Ti<Tj if Transaction Ti came into system before Tj.
The above scheme given is nothing but " Wound-Wait " Scheme in which younger transaction is killed by older transaction that
came into system before this younger transaction came.[1][2]
So, this is a part of Basic Time-Stamp Ordering in Concurrency Control.
And Basic Time Stamp ordering protocol is deadlock free and not starvation free, in general.
Here in this question according to given condition, the database system is both deadlock free and starvation free as well , as it is
Wound wait scheme and in case of wound wait it avoid starvation, because in Wound Wait scheme we restart a transaction
that has been aborted, with it's same original Timestamp . If it restart with a new Timestamp then there is a possibility of
Starvation ( as larger TimeStamp transaction is aborted here and new Transaction which is coming next have always
greater TimeStamp than previous one ). But that is Not the case here.
Reference:
[1] http://www.cs.colostate.edu/~cs551/CourseNotes/Deadlock/WaitWoundDie.html
[2] http://stackoverflow.com/questions/32794142/what-is-the-difference-between-wait-die-and-wound-wait
Hence, answer is (A).
PS: The Wound-wait scheme means :
The newer transactions are killed when an older transaction make a request for a lock being held by the
newer transactions .
Here the algorithm says TS(T2) < TS(T1) means T2 is older transaction ( as TS of T2 is less than TS of T1 ..means T2
come first then T1 come and TS is assign in increasing order ) , so newer one is T1 and also question says T1 holds
a lock on the resource R, and T2 has requested a conflicting lock on the same resource R.
So T1 is killed as per Wound-wait scheme .
Reference :
http://www.mathcs.emory.edu/~cheung/Courses/554/Syllabus/8-recv+serial/deadlock-compare.html
----------
' timestamps are assigned to each transaction using Lamport's logical clock.
T 1 is killed
else, T 2 waits.
comes under wound wait scheme..as here old transaction is always survive and older transaction wounds newer transaction when
both want to apply lock on same resource ..
Part 2 : Wound Wait avoid Starvation
Yes, How?
as newer one is die and restart with same timestamp and older one is survive always so after execute older transaction that newer
one can definitely execute and new transactions which are coming can die and restart again ( previous newer became older that
time).
Part 3 : Does Starvation freedom implies Deadlock freedom?
Yes, here no starvation means also No deadlock possibility.
In one line - wound wait -> no starvation -> no deadlock -> option A.
EDIT
Another way to think about Deadlock and starvation
Deadlock is prevented because we are violating NO-Preemption Condition for the deadlock to happen.
How starvation free? Here Bounded waiting for transactions is ensured.HOW?
Consider "n" transactions T1 , T2 . . . . Tn having their timestamps order as T S(T1 ) < T S(T2 ) <. . . . . T S(Tn ) (Timestamps are
unique)
Consider for k, 1 < k ≤ n a transaction Tk , this transaction Tk can be atmost preempted by Transaction sets T1 , T2 . . . . . . Tk−1
and it is also given "Any transaction that is not killed eventually terminates". Means Eventually a time would come when, all
transactions Tj having T S(Tj ) < T S(Tk ) will terminate and Tk would get chance without preemption.And this J would lie in
range 1 ≤ j ≤ k − 1 . Bounded waiting ensured.
References
3.17.1 Transaction And Concurrency: GATE CSE 1999 | Question: 2.6 top☝ ☛ https://gateoverflow.in/1484
Read A
A. This schedule is serializable and can occur in a scheme using 2PL protocol
B. This schedule is serializable but cannot occur in a scheme using 2PL protocol
C. This schedule is not serializable but can occur in a scheme using 2PL protocol
D. This schedule is not serializable and cannot occur in a scheme using 2PL protocol
Answer ☟
3.17.2 Transaction And Concurrency: GATE CSE 2003 | Question: 29, ISRO2009-73 top☝ ☛ https://gateoverflow.in/919
Which of the following scenarios may lead to an irrecoverable error in a database system?
Answer ☟
3.17.3 Transaction And Concurrency: GATE CSE 2003 | Question: 87 top☝ ☛ https://gateoverflow.in/970
Consider three data items D1, D2, and D3, and the following execution schedule of transactions T 1, T 2, and T 3. In the
diagram, R(D) and W(D) denote the actions reading and writing the data item D respectively.
T1 T2 T3
R(D3);
R(D2);
W(D2);
R(D2);
R(D3);
R(D1);
W(D1);
W(D2);
W(D3);
R(D1);
R(D2);
W(D2);
W(D1);
Answer ☟
3.17.4 Transaction And Concurrency: GATE CSE 2006 | Question: 20, ISRO2015-17 top☝ ☛ https://gateoverflow.in/981
Consider the following log sequence of two transactions on a bank account, with initial balance 12000, that transfer 2000 to a
mortgage payment and then apply a 5% interest.
1. T1 start
2. T1 B old = 12000 new = 10000
3. T1 M old = 0 new = 2000
4. T1 commit
5. T2 start
6. T2 B old = 10000 new = 10500
7. T2 commit
Suppose the database system crashes just before log record 7 is written. When the system is restarted, which one statement is true
of the recovery procedure?
Answer ☟
3.17.5 Transaction And Concurrency: GATE CSE 2007 | Question: 64 top☝ ☛ https://gateoverflow.in/1262
Consider the following schedules involving two transactions. Which one of the following statements is TRUE?
Answer ☟
3.17.6 Transaction And Concurrency: GATE CSE 2009 | Question: 43 top☝ ☛ https://gateoverflow.in/1329
Consider two transactions T1 and T2 , and four schedules S1 , S2 , S3 , S4 , of T1 and T2 as given below:
T1 : R1 [x]W1 [x]W1 [y]
T2 : R2 [x]R2 [y]W2 [y]
S1 : R1 [x]R2 [x]R2 [y]W1 [x]W1 [y]W2 [y]
S2 : R1 [x]R2 [x]R2 [y]W1 [x]W2 [y]W1 [y]
S3 : R1 [x]W1 [x]R2 [x]W1 [y]R2 [y]W2 [y]
S4 : R2 [x]R2 [y]R1 [x]W1 [x]W1 [y]W2 [y]
Answer ☟
3.17.7 Transaction And Concurrency: GATE CSE 2010 | Question: 20 top☝ ☛ https://gateoverflow.in/2196
Which of the following concurrency control protocols ensure both conflict serializability and freedom from deadlock?
I. 2-phase locking
II. Time-stamp ordering
A. I only
B. II only
C. Both I and II
D. Neither I nor II
Answer ☟
3.17.8 Transaction And Concurrency: GATE CSE 2010 | Question: 42 top☝ ☛ https://gateoverflow.in/2343
T1 T2 T3
Read(X)
Read(Y)
Read(Y)
Write(Y)
Write(X)
Write(X)
Read(X)
Write(X)
Which one of the schedules below is the correct serialization of the above?
A. T1 → T3 → T2
B. T2 → T1 → T3
C. T2 → T3 → T1
D. T3 → T1 → T2
Answer ☟
3.17.9 Transaction And Concurrency: GATE CSE 2012 | Question: 27 top☝ ☛ https://gateoverflow.in/1612
Consider the following transactions with data items P and Q initialized to zero:
A. a serializable schedule
B. a schedule that is not conflict serializable
C. a conflict serializable schedule
D. a schedule for which a precedence graph cannot be drawn
Answer ☟
3.17.10 Transaction And Concurrency: GATE CSE 2014 Set 1 | Question: 29 top☝ ☛ https://gateoverflow.in/1796
Consider the following four schedules due to three transactions (indicated by the subscript) using read and write on a data
item x, denoted by r(x) and w(x) respectively. Which one of them is conflict serializable?
Answer ☟
3.17.11 Transaction And Concurrency: GATE CSE 2014 Set 2 | Question: 29 top☝ ☛ https://gateoverflow.in/1988
T1 T2 T3 T4
Reads(X)
Writes(X)
Commit
Writes(X)
Commit
Writes(Y)
Reads(Z)
Commit
Reads(X)
Reads(Y)
Commit
Answer ☟
3.17.12 Transaction And Concurrency: GATE CSE 2014 Set 3 | Question: 29 top☝ ☛ https://gateoverflow.in/2063
Consider the transactions T 1, T 2, and T 3 and the schedules S1 and S2 given below.
Answer ☟
3.17.13 Transaction And Concurrency: GATE CSE 2015 Set 2 | Question: 1 top☝ ☛ https://gateoverflow.in/8047
The constraint that the sum of the accounts x and y should remain constant is that of
A. Atomicity
B. Consistency
C. Isolation
D. Durability
Answer ☟
3.17.14 Transaction And Concurrency: GATE CSE 2015 Set 2 | Question: 46 top☝ ☛ https://gateoverflow.in/8246
Consider a simple checkpointing protocol and the following set of operations in the log.
(start, T4); (write, T4, y, 2, 3); (start, T1); (commit, T4); (write, T1, z, 5, 7);
(checkpoint);
(start, T2); (write, T2, x, 1, 9); (commit, T2); (start, T3); (write, T3, z, 7, 2);
If a crash happens now and the system tries to recover using both undo and redo operations, what are the contents of the undo list
and the redo list?
A. Undo: T3, T1; Redo: T2
B. Undo: T3, T1; Redo: T2, T4
C. Undo: none; Redo: T2, T4, T3, T1
D. Undo: T3, T1, T4; Redo: T2
3.17.15 Transaction And Concurrency: GATE CSE 2015 Set 3 | Question: 29 top☝ ☛ https://gateoverflow.in/8482
Consider the partial Schedule S involving two transactions T 1 and T 2. Only the read and the write operations have been
shown. The read operation on data item P is denoted by read(P) and write operation on data item P is denoted by write(P) .
Schedule S
Time Instance Transaction ID
T1 T2
1 read(A)
2 write(A)
3 read(C)
4 write(C)
5 read(B)
6 write(B)
7 read(A)
8 commit
9 read(B)
Suppose that the transaction T 1 fails immediately after time instance 9. Which of the following statements is correct?
A. T 2 must be aborted and then both T 1 and T 2 must be re-started to ensure transaction atomicity
B. Schedule S is non-recoverable and cannot ensure transaction atomicity
C. Only T 2 must be aborted and then re-started to ensure transaction atomicity
D. Schedule S is recoverable and can ensure transaction atomicity and nothing else needs to be done
Answer ☟
3.17.16 Transaction And Concurrency: GATE CSE 2016 Set 1 | Question: 22 top☝ ☛ https://gateoverflow.in/39644
Which one of the following is NOT a part of the ACID properties of database transactions?
A. Atomicity
B. Consistency
C. Isolation
D. Deadlock-freedom
Answer ☟
3.17.17 Transaction And Concurrency: GATE CSE 2016 Set 1 | Question: 51 top☝ ☛ https://gateoverflow.in/39703
Consider the following two phase locking protocol. Suppose a transaction T accesses (for read or write operations), a certain
set of objects {O1 , … , Ok } . This is done in the following manner:
Answer ☟
Suppose a database schedule S involves transactions T1 , . . . . . . . . , Tn . Construct the precedence graph of S with vertices
representing the transactions and edges representing the conflicts.If S is serializable, which one of the following orderings of the
vertices of the precedence graph is guaranteed to yield a serial schedule?
A. Topological order
B. Depth-first order
C. Breadth- first order
D. Ascending order of the transaction indices
Answer ☟
3.17.19 Transaction And Concurrency: GATE CSE 2016 Set 2 | Question: 51 top☝ ☛ https://gateoverflow.in/39590
Answer ☟
3.17.20 Transaction And Concurrency: GATE CSE 2019 | Question: 11 top☝ ☛ https://gateoverflow.in/302837
I. Strict two-phase locking protocol generates conflict serializable schedules that are also recoverable.
II. Timestamp-ordering concurrency control protocol with Thomas’ Write Rule can generate view serializable schedules that are
not conflict serializable
Answer ☟
3.17.21 Transaction And Concurrency: GATE CSE 2020 | Question: 37 top☝ ☛ https://gateoverflow.in/333194
T1 RA RC WD WB Commit
T2 RB WB RD WC Commit
Here, RX stands for “Read(X)” and WX stands for “Write(X)”. Which one of the following schedules is conflict equivalent to the
above schedule?
T1 RA RC WD WB Commit
A.
T2 RB WB RD WC Commit
T1 RA RC WD WB Commit
B.
T2 RB WB RD WC Commit
Answer ☟
3.17.22 Transaction And Concurrency: GATE CSE 2021 Set 1 | Question: 13 top☝ ☛ https://gateoverflow.in/357439
Suppose a database system crashes again while recovering from a previous crash. Assume checkpointing is not done by the
database either during the transactions or during recovery.
Which of the following statements is/are correct?
A. The same undo and redo list will be used while recovering again
B. The system cannot recover any further
C. All the transactions that are already undone and redone will not be recovered again
D. The database will become inconsistent
Answer ☟
Which level of locking provides the highest degree of concurrency in a relational database ?
A. Page
B. Table
C. Row
D. Page, table and row level locking allow the same degree of concurrency
Answer ☟
T1 T2
Read(A)
A = A – 10
Read(A)
Temp = 0.2*A
Write(A)
Read(B)
Write(A)
Read(B)
B = B + 10
Write(B)
B = B + Temp
Write(B)
A. S is serializable only as T 1, T 2
B. S is serializable only as T 2, T 1
C. S is serializable both as T 1, T 2 and T 2, T 1
Answer ☟
Amongst the ACID properties of a transaction, the 'Durability' property requires that the changes made to the database by a
successful transaction persist
Answer ☟
A company maintains records of sales made by its salespersons and pays them commission based on each individual's total
sales made in a year. This data is maintained in a table with following schema:
salesinfo = (salespersonid, totalsales, commission)
In a certain year, due to better business results, the company decides to further reward its salespersons by enhancing the commission
paid to them as per the following formula:
If commission ≤ 50000, enhance it by 2%
If 50000 < commission ≤ 100000, enhance it by 4%
If commission > 100000, enhance it by 6%
The IT staff has written three different SQL scripts to calculate enhancement for each slab, each of these scripts is to run as a
separate transaction as follows:
T1 Update salesinfo
Set commission = commission * 1.02
Where commission < = 50000;
T2 Update salesinfo
Set commission = commission * 1.04
Where commission > 50000 and commission is < = 100000;
T3
Update salesinfo
Set commission = commission * 1.06
Where commission > 100000;
Which of the following options of running these transactions will update the commission of all salespersons correctly
Answer ☟
Answer ☟
Consider the following three schedules of transactions T1, T2 and T3. [Notation: In the following NYO represents the action
Y (R for read, W for write) performed by transaction N on object O.]
Answer ☟
3.17.1 Transaction And Concurrency: GATE CSE 1999 | Question: 2.6 top☝ ☛ https://gateoverflow.in/1484
If we draw the precedence graph we get a loop,and hence the schedule is not conflict serializable.
There is no blind write too so ,there is no chance that view serializability can occur.
Now 2pl ensures CS.
Since possiblity of CS is ruled out at the onset,so schedule cannot occur in 2PL.
Ans d)
3.17.2 Transaction And Concurrency: GATE CSE 2003 | Question: 29, ISRO2009-73 top☝ ☛ https://gateoverflow.in/919
A. Here if transaction writing data commits , then transaction which read the data might get phantom tuple/ Unrepeatable
error. Though there is no irrecoverable error possible even in this option.
B. This is non issue. Both transaction reading data.
C. This is non issue.
D. This is dirty read. In case if transaction reading uncommitted data commits, irrecoverable error occurs of uncommitted
transaction fails. So (D) is answer
3.17.3 Transaction And Concurrency: GATE CSE 2003 | Question: 87 top☝ ☛ https://gateoverflow.in/970
There is a cycle in precedence graph so schedule is not conflict serialisable.
Check View Serializability:
Checking View Serializability is NPC problem so proving by contradiction..
1. Initial Read
T 2 read D2 value from initial database and T 1 modify D2 so T 2 should execute before T 1.
i.e., T 2 → T 1
2. Final write.
final write of D1 in given schedule done by T 2 and T 1 modify D1 i.e. W(D1)..
that means T 2 should execute after T 1.
i.e., T 1 → T 2
3.17.4 Transaction And Concurrency: GATE CSE 2006 | Question: 20, ISRO2015-17 top☝ ☛ https://gateoverflow.in/981
Answer should be B. Here we are not using checkpoints so, redo log records 2 and 3 and undo log record 6.
Consider the following steps taken from the book 'Navathe':
PROCEDURE RIU_M
1. Use two lists of transactions maintained by the system: the committed transactions since the last checkpoint and the active
transactions
2. Undo all the write _item operations of the active (uncommitted) transaction, using the UNDO procedure. The operations
should be undone in the reverse order in which they were written into the log.
3. Redo all the write _item operations of the committed transactions from the log, in the order in which they were written
into the log.
3.17.5 Transaction And Concurrency: GATE CSE 2007 | Question: 64 top☝ ☛ https://gateoverflow.in/1262
For S1 : it is not conflict serializable
For S2 : it is conflict serializable
Answer is option C.
3.17.6 Transaction And Concurrency: GATE CSE 2009 | Question: 43 top☝ ☛ https://gateoverflow.in/1329
The answer is B.
A schedule is conflict serializable if there is no cycle in the directed graph made by the schedules.
In the schedules we check for RW, WR, WW conflicts between the schedules and only these conflicts contribute in the edges of
the graph.
3.17.7 Transaction And Concurrency: GATE CSE 2010 | Question: 20 top☝ ☛ https://gateoverflow.in/2196
In basic two phase locking there is a chance for deadlock
I go with B.
49 votes -- Sankaranarayanan P.N (8.5k points)
Answer is option A.
create precedence graph and apply Topological sort on it to obtain
T1 → T3 → T2
References
3.17.9 Transaction And Concurrency: GATE CSE 2012 | Question: 27 top☝ ☛ https://gateoverflow.in/1612
Answer is (B). Explanation: T 1 : r(P), r(Q), w(Q)T 2 : r(Q), r(P), w(P) now, consider any non serial schedule for
example, S : r1(P), r2(Q), r1(Q), r2(P), w1(Q), w2(P) now, draw a precedence graph for this schedule. here there is a
conflict from T 1− > T 2 and there is a conflict from T 2− > T 1 therefore, the graph will contain a cycle. so we can say that
the schedule is not conflict serializable.
68 votes -- jayendra (6.7k points)
3.17.10 Transaction And Concurrency: GATE CSE 2014 Set 1 | Question: 29 top☝ ☛ https://gateoverflow.in/1796
(D) make precedence graph for all the options, for option (D) only graph will be acyclic, hence (D) is CSS.
3.17.11 Transaction And Concurrency: GATE CSE 2014 Set 2 | Question: 29 top☝ ☛ https://gateoverflow.in/1988
Answer: S is both conflict serializable and recoverable.
Recoverable? Look if there are any dirty reads? Since there are no dirty read, it simply implies schedule is recoverable( if there
were dirty read, then we would have taken into consideration the order in which transactions commit)
Conflict serializable? Draw the precedence graph( make edges if there is a conflict instruction among Ti and Tj. But for the given
schedule, no cycle exists in precedence graph, thus it's conflict serializable.
Even though @Ramandeep Singh has answered this question, I'd like to add some additional points because in the comments and
discussion on this question, many students are having incorrect arguments which they think are correct.
The Mistake that most students are doing (in the comments to this question) is that they are Not making correct Precedence
Graph because they are not making conflict edges in the Precedence graph "from a committed transaction to a newly started
transaction"....which is completely wrong because if you do so then How will you make Precedence Graph for Serial Schedule??
Following all the definitions and concepts are directly (without modification) picked mostly from Navathe and some from the
following link : http://www.ict.griffith.edu.au/~rwt/uoe/1.1.ccc.html
Transactions :
A transaction is effectively a sequence of read and write operations on atomic database items. A transaction may be incomplete
because the (database) system crashes, or because it is aborted by either the system or the user (or application). Complete
transactions are committed. Transactions must terminate by either aborting or committing.
Complete Schedule :
A schedule S of n transactions T 1, T 2, … , T n is said to be a complete schedule if the following conditions hold:
1. The operations in S are exactly those operations in T 1, T 2, … , T n , including a commit or abort operation as the last
operation for each transaction in the schedule.
2. For any pair of operations from the same transaction T i , their relative order of appearance in S is the same as their order of
appearance in T i . (i.e Operation order in/of every transaction must preserve.)
3. For any two conflicting operations, one of the two must occur before the other in the schedule.
Condition 1 simply states that all operations in the transactions must appear in the complete schedule. Since every transaction has
either committed or aborted, a complete schedule will not contain any active transactions at the end of the schedule.
In general, it is difficult to encounter complete schedules in a transaction processing system because new transactions are
continually being submitted to the system. Hence, it is useful to define the concept of the committed projection C(S) of a
schedule S .
Serial Schedule (Definition as it is given in Navathe) : Formally, a schedule S is serial if, for every transaction T participating
in the schedule, all the operations of T are executed consecutively in the schedule; otherwise, the schedule is called nonserial.
Therefore, in a serial schedule, only one transaction at a time is active—the commit (or abort) of the active transaction initiates
execution of the next transaction. No interleaving occurs in a serial schedule.
S = R1 (X) W1 (X) C1 R2 (X) W2 (X) C2 R3 (X) W3 (X) C3
If you make precedence graph for this schedule, then you must get a acyclic precedence graph But those students who are not
putting conflict edges in the precedence graph "from a committed transaction to a newly started transaction" then you won't get
any edges in this graph and the graph will be empty graph, which you know is not correct.
T1 T2 T3
Write(X)
Writes(Z)
Writes(X)
Commit
Writes(Y)
Reads(Y)
Writes(Z)
Writes(M)
Commit
Reads(M)
Commit
3.17.12 Transaction And Concurrency: GATE CSE 2014 Set 3 | Question: 29 top☝ ☛ https://gateoverflow.in/2063
3.17.13 Transaction And Concurrency: GATE CSE 2015 Set 2 | Question: 1 top☝ ☛ https://gateoverflow.in/8047
B. Consistency
In the given transaction Atomicity guarantees that the said constraint is satisfied. But this constraint is not part of Atomicity
property. It is just that Atomicity implies Consistency here.
23 votes -- Arjun Suresh (332k points)
3.17.14 Transaction And Concurrency: GATE CSE 2015 Set 2 | Question: 46 top☝ ☛ https://gateoverflow.in/8246
T1 T2 T3 T4
start
w(y, 2, 3)
start
commit
w(z, 5, 7)
checkpoint checkpoint checkpoint checkpoint
start
w(x, 1, 9)
commit
start
w(z, 7, 2)
crash crash crash crash
Now from the table we can find that T 1 and T 3 has uncommitted write operation, so they must be undone. Even though T 2 has
committed after writing, but it is after checkpoint. So, it needs to be redone.
Answer is A.
71 votes -- worst_engineer (2.8k points)
The correct option is B.
Why A is not correct because it says abort transaction T2 and then redo all the operations .
But is there a guarantee that it will succeed this time ??(no maybe again T1 will fail).
Now as to why b is correct because as the other answer points out it is by definition an irrecoverable schedule now even if
we start to undo the actions on by one(after t1 fails) in order to ensure transaction atomicity. Still we cannot undo a
committed transaction. Hence, this schedule is unrecoverable by definition and also not atomic since it leaves the data base in
an inconsistent state.
3.17.16 Transaction And Concurrency: GATE CSE 2016 Set 1 | Question: 22 top☝ ☛ https://gateoverflow.in/39644
A - Atomicity
C - Consistency
I - Isolation
D - Durability.
Answer (D)
3.17.17 Transaction And Concurrency: GATE CSE 2016 Set 1 | Question: 51 top☝ ☛ https://gateoverflow.in/39703
Two Phase Locking protocol is conflict serializable. So this is a modified version of the basic 2PL protocol, So
serializabilty should be guaranteed.. and we can get a serializable scheduling by ordering based on Lock points(same as in basic
2PL
)..
Now in Step 1, exclusive locks are aquired to O1 , O2 , O3 .... in increasing order of addresses..since it is mentioned as exclusive
lock, only one transaction can lock the object..
Due to acquiring of locks based on ordering of addresses.. and locks aren't released until the
transaction completes its operation.. we can prevent the circular wait condition, and hence making it
deadlock free.
So, the answer should be (A) guarantees serializability and deadlock freedom
3.17.18 Transaction And Concurrency: GATE CSE 2016 Set 2 | Question: 22 top☝ ☛ https://gateoverflow.in/39550
Topological Order.
24 votes -- Sharathkumar Anbu (595 points)
3.17.19 Transaction And Concurrency: GATE CSE 2016 Set 2 | Question: 51 top☝ ☛ https://gateoverflow.in/39590
Answer is C
T1 T2
R(x)
R(x)
R(y)
W(x)
R(y)
W(x)
a1
a2
3.17.20 Transaction And Concurrency: GATE CSE 2019 | Question: 11 top☝ ☛ https://gateoverflow.in/302837
1. Strict 2PL allows only schedules whose precedence graph is acyclic i.e. schedule is Conflict Serial. In 2PL, transactions do
not release exclusive locks until the transaction has committed or aborted i.e. schedule is recoverable.
2. Time stamp ordering schedule with Thomas write rule generate View serial schedule with BLIND WRITE. Because of
BLIND WRITE it won't be Conflict Serial.
3.17.21 Transaction And Concurrency: GATE CSE 2020 | Question: 37 top☝ ☛ https://gateoverflow.in/333194
If you draw the dependency graph, you'll notice that there is a cycle. Hence Option (D) and Option (B) are straightaway
False.
Now in Option (C), there is a swapping operation of conflicting operations W1 (D) and R2 (D). Hence it's False as well.
Hence, Option(A) is the answer
3.17.22 Transaction And Concurrency: GATE CSE 2021 Set 1 | Question: 13 top☝ ☛ https://gateoverflow.in/357439
Answer: A
Explanation:
Support for option A and against option C: Since check-pointing is not used we have to depend on the system logs. Let's
suppose we have three transactions A, B and C. Also assume that transaction A and C commits before failure and B was started
but the system crashed before it can commit. So, in the first recovery process database will redo A and C as per the system logs.
Now consider that while redoing A successfully commits, the system crashed for the second time before the B can commit. So,
while recovering for the second time the same system logs will be used. However, it is should be noted that the system logs will
also have entry to redo transaction A since it was committed after the first failure. However, the undo/redo operations are
idempotent (they are the same no matter how many time they are executed).
Against option B: If the system crashes again same logic as above can be used for recovery.
Against option D: Inconsistency refers to situations (generally) when the value of a shared variable varies in two or more
transactions, but that doesn’t seem to happen here as no uncommitted transaction’s data is being read/written during the entire
recovery process.
Conclusion: So, the only option of selecting the same list for undo/redo seems to be correct.
Row level locking provides more concurrency, because different transactions can access different rows in a table / page
at same time,
Correct Answer: C
41 votes -- Sankaranarayanan P.N (8.5k points)
There is a cycle in the precedence graph - so the given schedule is not Conflict Serializable.
If a schedule is view serializable but not conflict serializable it MUST have one or more blind writes. Here, there is no blind
writes. So, the given schedule is not even view serializable.
Option D is the Answer.
Answer d. Irrespective of any failure the successful result of transaction should persist.
Then when we are going to board the train on that time they tells because of system/disk/power crash they dont have your seat
information and you are not allowed in the seat.
Correct Answer : D
so, he wil get increment two times. but he is eligible for only one slab of commision.
Answer is (C).
Many of you would point a DEADLOCK and I won't deny But see Question just asks for requirement to follow Strict 2PL.
Requirement are
In 2Pl deadlock may occur BUT it may be that it doesn't occur at all.
Consider that in option (C) if both execute in serial order without concurrency. Then that is perfectly valid and YES it follows
Strict 2PL.
Two schedules are conflict equivalent if we can derive one schedule by swapping the non-conflicting operations of the
other schedule.
S1
T1 T2 T3
R(A)
W(A)
R(C)
W(B)
W(A)
W(C)
R(A)
R(B)
W(A)
W(B)
Here, we can swap R(C) and W(B) since they are non-conflicting pair (since they are operating on different data items)
After swapping the schedule will become T 2 → T 3 → T 1
T1 T2 T3
R(A)
W(A)
W(B)
R(C)
W(A)
W(C)
R(A)
R(B)
W(A)
W(B)
S2
T1 T2 T3
R(C)
R(A)
W(A)
W(B)
W(A)
R(A)
R(B)
W(A)
W(B)
W(C)
Here, we can swap and write R(C) after performing T2 operations:- R(A), W(A) and W(B) since each of them form non-
conflicting pair with R(C) (since they are operating on different data items)
Also, we can swap W(C) and can execute it before all the T1 operations as each of the t1 operations are forming non-conflicting
pair with W(C) (since they are operating on different data items)
After swapping the schedule will become T 2 → T 3 → T 1
S3
T1 T2 T3
R(A)
R(C)
W(A)
W(A)
W(B)
W(C)
R(A)
R(B)
W(A)
W(B)
Here, we can't swap the operations and make it as T 2 → T 3 → T 1 because of the conflicting pairs W(A)and W(A)
∴ Option D. S1 is conflict equivalent to S2, but not to S3 is the correct answer.
Answer Keys
3.5.4 N/A 3.5.5 N/A 3.5.6 N/A 3.5.7 B;D 3.5.8 False
3.15.3 N/A 3.15.4 N/A 3.15.5 N/A 3.15.6 N/A 3.15.7 N/A