GATE 2001
60 questions
MCQ 601-mark 60
Questions 56–60 of 60
Let r and s be two relations over the relation schemes R and S respectively, and let A be an attribute in R. Then the relational algebra expression is always equal to :
Answer: (C)
A is an attribute of , so each tuple of has its value copied from its part. So the selection can be done on before the join:
This holds in every case. Even if also occurs in , the join forces equal values, so the check can still be made on .
(A) is wrong: has only the attributes of and keeps tuples that have no match in .
(B) is wrong: it has no selection and no join with .
Answer: (C)
This holds in every case. Even if also occurs in , the join forces equal values, so the check can still be made on .
(A) is wrong: has only the attributes of and keeps tuples that have no match in .
(B) is wrong: it has no selection and no join with .
Answer: (C)
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: (D)
- (A) A selection on X followed by a projection on Y: . This has a fixed length.
- (B) Select the tuples with and project X: . This has a fixed length.
- (C) A cycle of fewer than three vertices is a self loop (length 1) or a 2-cycle (length 2). A self loop is the same as in (B). For a 2-cycle, join Adj with a copy of itself on and , then project X. This also has a fixed length, and it does not depend on the number of tuples.
- (D) Reachability is the transitive closure of Adj. A path can be as long as the number of vertices, say in a long chain, so we would need that many joins. The query length would grow with the graph, so no expression of constant length can do it.
Answer: (D)
- (B) Select the tuples with and project X: . This has a fixed length.
- (C) A cycle of fewer than three vertices is a self loop (length 1) or a 2-cycle (length 2). A self loop is the same as in (B). For a 2-cycle, join Adj with a copy of itself on and , then project X. This also has a fixed length, and it does not depend on the number of tuples.
- (D) Reachability is the transitive closure of Adj. A path can be as long as the number of vertices, say in a long chain, so we would need that many joins. The query length would grow with the graph, so no expression of constant length can do it.
Answer: (D)
Which of the following relational calculus expressions is not safe ?
Answer: (C)
Answer: C.
This expression gives all tuples that are not in R1. There are infinitely many such tuples, so the expression is not safe.
Reference: https://people.cs.pitt.edu/~chang/156/10calculus.html
Consider a relation geq which represents "greater than or equal to", that is, (x,y) geq only if yx:
create table geq
(
ib integer not null
ub integer not null
primary key ib
foreign key (ub) references geq on delete cascade
) Which of the following is possible if a tuple (x,y) is deleted ?Answer: (C)
Each tuple of geq has . is the primary key, so no two tuples have the same first value. is a foreign key to with on delete cascade, so deleting a tuple also deletes every tuple whose equals the deleted , and so on down the chain.
Delete .
- Level 1: tuples with are deleted. Here , and because is already used by . So .
- Level 2: tuples with are deleted. Here the second value is .
So a deleted tuple with is possible, which is option C.
Every cascaded tuple has , so a tuple with is never deleted. That rules out B, and also A, because makes even larger than . D is wrong because cascade lets the deletion go through.
Answer: (C)
Delete .
- Level 1: tuples with are deleted. Here , and because is already used by . So .
- Level 2: tuples with are deleted. Here the second value is .
So a deleted tuple with is possible, which is option C.
Every cascaded tuple has , so a tuple with is never deleted. That rules out B, and also A, because makes even larger than . D is wrong because cascade lets the deletion go through.
Answer: (C)
R,(A,B,C,D) is a relation. Which of the following does not have a lossless join, dependency preserving BCNF decomposition ?
Answer: (C)
For each option, find the keys, split the relation so that every part is in BCNF, and check that the join is lossless and every FD is kept.
(A) . The key is . Split into and . In the key is ; in it is , and each FD has the key of its relation on the left, so both are in BCNF. The common attribute is a key of , so the join is lossless. Each FD sits inside one relation, so both are preserved.
(B) . The key is . Split into , and . The left side of each FD is the key of its relation, so all three are in BCNF. Joining and on (a key of ), then joining on (a key of ), is lossless. All three FDs are preserved.
(D) . is a key of , so is already in BCNF. It can be kept as it is, or split into , , ; each has key , the join on is lossless, and every FD is preserved.
(C) . The keys are and . Since is not a super key, breaks BCNF in , so must be split. To preserve , the attributes must stay together in one relation. That relation is either or . In , holds and is not a super key. In , violates BCNF. So no dependency-preserving decomposition is in BCNF.
The question asks for the set that does not have such a decomposition.
Answer: (C)
(A) . The key is . Split into and . In the key is ; in it is , and each FD has the key of its relation on the left, so both are in BCNF. The common attribute is a key of , so the join is lossless. Each FD sits inside one relation, so both are preserved.
(B) . The key is . Split into , and . The left side of each FD is the key of its relation, so all three are in BCNF. Joining and on (a key of ), then joining on (a key of ), is lossless. All three FDs are preserved.
(D) . is a key of , so is already in BCNF. It can be kept as it is, or split into , , ; each has key , the join on is lossless, and every FD is preserved.
(C) . The keys are and . Since is not a super key, breaks BCNF in , so must be split. To preserve , the attributes must stay together in one relation. That relation is either or . In , holds and is not a super key. In , violates BCNF. So no dependency-preserving decomposition is in BCNF.
The question asks for the set that does not have such a decomposition.
Answer: (C)