GATE 2012
82 questions
MCQ 821-mark 39 · 2-mark 43
Questions 51–55 of 82
Consider the following relations A, B and C:
How many tuples does the result of the following relational algebra expression contain? Assume that the schema of AB is the same as that of A.
How many tuples does the result of the following relational algebra expression contain? Assume that the schema of AB is the same as that of A.
Answer: (A)
The union A B, with duplicates removed, gives 5 tuples. Their Ids are 12, 15, 99, 25, 98.
- Take C.Id = 10. The condition 10 15 is true, so all 5 tuples match.
- Take C.Id = 99. Only tuples with Id 40 match. These are 99 and 98 2 tuples.
Total = 5 + 2 = 7
Answer: 7
- Take C.Id = 10. The condition 10 15 is true, so all 5 tuples match.
- Take C.Id = 99. Only tuples with Id 40 match. These are 99 and 98 2 tuples.
Total = 5 + 2 = 7
Answer: 7
Suppose R1(A, B) and R2(C, D) are two relation schemas. Let r1 and r2 be the corresponding relation instances. B is a 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?
Answer: (A)
Under referential integrity, each B value in r1 must also be present as a C value in r2. This gives , which means .
Both sides need not be equal, because r2 may hold C values that no tuple in r1 refers to.
Answer:
Both sides need not be equal, because r2 may hold C values that no tuple in r1 refers to.
Answer:
Consider the following relations A, B and C:
How many tuples does the result of the following SQL query contain?
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') Answer: (B)
B has no 'Arun', so the subquery returns an empty set. The condition " ALL (empty set)" is true for every row.
So all 3 tuples of A are in the result.
Answer: 3
So all 3 tuples of A are in the result.
Answer: 3
Which of the following statements are TRUE about an SQL query?
P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause
Q : An SQL query can contain a HAVING clause only if it has a GROUP BY clause
R : All attributes used in the GROUP BY clause must appear in the SELECT clause
S : Not all attributes used in the GROUP BY clause need to appear in the SELECT clause
P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause
Q : An SQL query can contain a HAVING clause only if it has a GROUP BY clause
R : All attributes used in the GROUP BY clause must appear in the SELECT clause
S : Not all attributes used in the GROUP BY clause need to appear in the SELECT clause
Answer: (B)
P is true, Q is false. In standard SQL a HAVING clause can be used without GROUP BY. The whole table is then treated as one group. For example,
S is true, R is false. Columns in GROUP BY do not have to appear in SELECT. For example,
So P and S are true.
Answer: (B)
SELECT COUNT(*) FROM T HAVING COUNT(*) > 5 is valid.S is true, R is false. Columns in GROUP BY do not have to appear in SELECT. For example,
SELECT COUNT(*) FROM T GROUP BY dept is valid. (The reverse is the real rule: a plain column in SELECT must be in GROUP BY.)So P and S are true.
Answer: (B)
Which of the following is TRUE?
Answer: (C)
BCNF is a stronger form than 3NF. Each relation in BCNF is also in 3NF, but a 3NF relation need not be in BCNF.
Option 2 talks about 2NF (no partial dependency), and not 3NF.
Answer: Every relation in BCNF is also in 3NF
Option 2 talks about 2NF (no partial dependency), and not 3NF.
Answer: Every relation in BCNF is also in 3NF