GATE 2010
82 questions
MCQ 821-mark 39 · 2-mark 43
Questions 51–55 of 82
The following functional dependencies hold for relations R(A, B, C) and S(B, D, E)
B A,
A C
The relation R contains 200tuples and the relation S contains 100tuples. What is the maximum number of tuples possible in the natural join R S?
B A,
A C
The relation R contains 200tuples and the relation S contains 100tuples. What is the maximum number of tuples possible in the natural join R S?
Answer: (A)
Look at R. We have B A and A C, so B is a key of R. When we join on B, each tuple of S matches at most one tuple of R.
Maximum size of the join = |S| = 100
Answer: 100
Maximum size of the join = |S| = 100
Answer: 100
A relational schema for a train reservation database is given below
What pids are returned by the following SQL query for the above instance of the tables?
What pids are returned by the following SQL query for the above instance of the tables?
SELECT pid
FROM Reservation
WHERE class = 'AC' AND
EXISTS (SELECT *
FROM Passenger
WHERE age > 65 AND
Passenger.pid = Reservation.pid) Answer: (C)
Reservations with class AC have pids 0, 1, 5 and 3.
Now check which of these have a passenger with age 65:
- pid 0: age is 65 no
- pid 1: age is 66 yes
- pid 5: no matching passenger no
- pid 3: age is 69 yes
Answer: 1, 3
Now check which of these have a passenger with age 65:
- pid 0: age is 65 no
- pid 1: age is 66 yes
- pid 5: no matching passenger no
- pid 3: age is 69 yes
Answer: 1, 3
Consider the following schedule for transactions T1, T2 and T3:
Which one of the schedules below is the correct serialization of the above?
Which one of the schedules below is the correct serialization of the above?
Answer: (A)
Conflicting operations (same item, different transactions, at least one write) give these edges:
- T1 does R(X) and W(X) before T3 does W(X), so
- T1 does W(X) before T2 does R(X), so
- T3 does R(Y) before T2 does W(Y), so
- T3 does W(X) before T2 does R(X) and W(X), so
The graph has no cycle, and the only order that respects all edges is .
Answer: (A)
- T1 does R(X) and W(X) before T3 does W(X), so
- T1 does W(X) before T2 does R(X), so
- T3 does R(Y) before T2 does W(Y), so
- T3 does W(X) before T2 does R(X) and W(X), so
The graph has no cycle, and the only order that respects all edges is .
Answer: (A)
Which of the following concurrency control protocols ensure both conflict serializability and freedom from deadlock?
I. 2-phase locking
II. Time-stamp ordering
I. 2-phase locking
II. Time-stamp ordering
Answer: (B)
Let us look at each protocol:
- 2PL gives conflict serializability, but deadlock can happen.
- Timestamp ordering is serializable in the order of the timestamps. It never makes transactions wait in a cycle, because it aborts them instead so it is free from deadlock.
Answer: II only
- 2PL gives conflict serializability, but deadlock can happen.
- Timestamp ordering is serializable in the order of the timestamps. It never makes transactions wait in a cycle, because it aborts them instead so it is free from deadlock.
Answer: II only
Consider a network with 6 routers R1 to R6 connected with links having weights as shown in the following diagram
Suppose the weights of all unused links in the previous question (R1-R2 and R4-R6, which carry no data with the weights shown) are changed to 2 and the distance vector algorithm is used again until all routing tables stabilize. How many links will now remain unused?
Suppose the weights of all unused links in the previous question (R1-R2 and R4-R6, which carry no data with the weights shown) are changed to 2 and the distance vector algorithm is used again until all routing tables stabilize. How many links will now remain unused?
Answer: (B)
In the previous graph two links were unused because a shorter path existed: R1-R2 (6) loses to R1-R3-R2 , and R4-R6 (8) loses to R4-R5-R6 . Both now get weight .
Links now: R1-R2 2, R1-R3 3, R2-R3 2, R2-R4 7, R3-R5 9, R4-R5 1, R4-R6 2, R5-R6 4. Check each one against the best alternative path between its end points:
- R1-R2 (2): other path R1-R3-R2 is 5. Used.
- R1-R3 (3): other path R1-R2-R3 is . Used.
- R2-R3 (2): other path R2-R1-R3 is . Used.
- R2-R4 (7): other path R2-R3-R5-R4 is . Used.
- R3-R5 (9): other path R3-R2-R4-R5 is . Used.
- R4-R5 (1): cheapest possible. Used.
- R4-R6 (2): other path R4-R5-R6 is . Used.
- R5-R6 (4): other path R5-R4-R6 is , which is shorter. Never used.
Only R5-R6 is left unused, so 1 link.
Answer: (B)
Links now: R1-R2 2, R1-R3 3, R2-R3 2, R2-R4 7, R3-R5 9, R4-R5 1, R4-R6 2, R5-R6 4. Check each one against the best alternative path between its end points:
- R1-R2 (2): other path R1-R3-R2 is 5. Used.
- R1-R3 (3): other path R1-R2-R3 is . Used.
- R2-R3 (2): other path R2-R1-R3 is . Used.
- R2-R4 (7): other path R2-R3-R5-R4 is . Used.
- R3-R5 (9): other path R3-R2-R4-R5 is . Used.
- R4-R5 (1): cheapest possible. Used.
- R4-R6 (2): other path R4-R5-R6 is . Used.
- R5-R6 (4): other path R5-R4-R6 is , which is shorter. Never used.
Only R5-R6 is left unused, so 1 link.
Answer: (B)