GATE 2005
203 questions
MCQ 2031-mark 203
Questions 166–170 of 203
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
where T.price > B.price) < 5 Answer: (D)
For each book B, the subquery counts the books T that cost more than B. The condition keeps B when this count is less than 5, that is, when the count is 0, 1, 2, 3 or 4.
Prices are all different. The most expensive book has count 0, the second most expensive has count 1, and so on, up to the fifth most expensive with count 4. The sixth most expensive has count 5, so it is not kept. So the query lists the five most expensive books.
(A) is wrong because five books qualify, not four. (B) is about the cheap end, but the query counts books that cost more.
Answer: (D)
Prices are all different. The most expensive book has count 0, the second most expensive has count 1, and so on, up to the fifth most expensive with count 4. The sixth most expensive has count 5, so it is not kept. So the query lists the five most expensive books.
(A) is wrong because five books qualify, not four. (B) is about the cheap end, but the query counts books that cost more.
Answer: (D)
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.
The set of all tuples that must be additionally deleted to preserve referential integrity when the tuple (2,4) is deleted is:
The set of all tuples that must be additionally deleted to preserve referential integrity when the tuple (2,4) is deleted is:
Answer: (C)
(C)
We delete . is a primary key, so its foreign key rows and must go too.
Now and are deleted, so their foreign key row must go as well.
No foreign key row refers to .
In a schema with attributes A, B, C, D and E following set of functional dependencies are given
Which of the following functional dependencies is NOT implied by the above set?
Which of the following functional dependencies is NOT implied by the above set?
Answer: (B)
Check each FD by computing the closure of its left side.
- (A) : : gives ; gives ; gives . So , which contains . Implied.
- (B) : : adds nothing new, and no other FD has a left side inside . So , which does not contain . Not implied.
- (C) : : gives ; gives ; gives . So , which contains . Implied.
- (D) : gives , so contains (in fact ). Implied.
Answer: (B)
- (A) : : gives ; gives ; gives . So , which contains . Implied.
- (B) : : adds nothing new, and no other FD has a left side inside . So , which does not contain . Not implied.
- (C) : : gives ; gives ; gives . So , which contains . Implied.
- (D) : gives , so contains (in fact ). Implied.
Answer: (B)
A table has fields with the following functional dependencies
In terms of Normalization, this table is in
In terms of Normalization, this table is in
Answer: (A)
Find the key. and appear on no right side, so both are in every key. : , and give all of . Neither nor alone determines everything (, ). So the only key is .
and are partial dependencies: a part of the key decides a non-key attribute. So the table is not in 2NF. Values are atomic, so it is in 1NF.
Answer: (A)
and are partial dependencies: a part of the key decides a non-key attribute. So the table is not in 2NF. Values are atomic, so it is in 1NF.
Answer: (A)
Which one of the following statements about normal forms is FALSE?
Answer: (C)
Option (C) is the FALSE statement.
A lossless decomposition into can always be done. But a decomposition that is both lossless and dependency preserving cannot always be done. For example, with and cannot be split into BCNF relations without losing . Such a decomposition is always possible for
Option (A) is true. A relation in is always in . In fact, allows an FD whose left side is not a superkey when the right side is prime, while does not.
Option (D) is true. Take the two attributes as and There are three cases:
1. Only one of or holds. No other non-trivial FD is possible. The left side of every FD is a superkey, so the rule is met.
2. Both and hold. Both and are keys, so the rule is met as above.
3. Neither holds, so is the key. No non-trivial FD is possible, so the rule is met.
So any relation with attributes is in Option (B) is true, since the 3NF synthesis algorithm gives a lossless, dependency-preserving decomposition.
Answer: (C)
A lossless decomposition into can always be done. But a decomposition that is both lossless and dependency preserving cannot always be done. For example, with and cannot be split into BCNF relations without losing . Such a decomposition is always possible for
Option (A) is true. A relation in is always in . In fact, allows an FD whose left side is not a superkey when the right side is prime, while does not.
Option (D) is true. Take the two attributes as and There are three cases:
1. Only one of or holds. No other non-trivial FD is possible. The left side of every FD is a superkey, so the rule is met.
2. Both and hold. Both and are keys, so the rule is met as above.
3. Neither holds, so is the key. No non-trivial FD is possible, so the rule is met.
So any relation with attributes is in Option (B) is true, since the 3NF synthesis algorithm gives a lossless, dependency-preserving decomposition.
Answer: (C)