0% found this document useful (0 votes)
21 views5 pages

Query Language _ DPP 03 (of Lec 09)

The document contains a series of multiple-choice questions (MCQs) and multiple-select questions (MSQs) related to Database Management Systems, specifically focusing on relational algebra and SQL queries. It includes various queries, their equivalent expressions, and the correct answers for each question. Additionally, hints and solutions for the questions are provided to aid understanding.

Uploaded by

Jaswant Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views5 pages

Query Language _ DPP 03 (of Lec 09)

The document contains a series of multiple-choice questions (MCQs) and multiple-select questions (MSQs) related to Database Management Systems, specifically focusing on relational algebra and SQL queries. It includes various queries, their equivalent expressions, and the correct answers for each question. Additionally, hints and solutions for the questions are provided to aid understanding.

Uploaded by

Jaswant Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1

Branch : CSE & IT Batch : Hinglish


Database Management System
Query Language DPP 03

[MCQ] List-I List-II


1. Consider the following relational algebra query on 1. a1  a2 (a) {<p, q, r > |< p, q, r > a1v <p, q, r > 
relations A (p, q, r) and B (q, r): a2}
p(A) – p((p (A) × q,r (B) –p,q,r (A)) 2. a1  a2 (b) {<p, q, r> |<p, q, r >a1  < p, q, r > 
The above query is equivalent to? a2}
(a) A  B 3. a1 – a2 (c) {<p, q, r > | < p,q,r, > |  a1  <p, q ,r >
(b) A  B  a2}
(c) A – B
(d) A ÷ B (a) 1– (a), 2 – (b), 3 – (c)
(b) 1– (b), 2 – (c), 3 – (a)
[MCQ] (c) 1– (a), 2 – (c), 3 – (b)
2. Consider the following SQL query. (d) 1– (b), 2 – (a), 3 – (c)
SELECT DISITNCT P1, P2, P3…. Pn
[NAT]
FROM R1, R2, R3….. Rm
5. Consider the table which contains the data shown
WHERE Q below.
Which of the following relational algebra query is Sailors (SailID, SailName, Rating, Age)
equivalent to above SQL query? Reserves (SailID, BoatID, Date)
(a) P1, P2, P3…. Pn(Q (R1 ⋈ R2 ⋈ R3⋈……⋈ Rm)) Boats (BoatID, BoatName, Color)
(b) P1, P2, P3…. Pn((R1× R2 × R3×…… ×Rm) Sailors
SailID SailName Rating Age
(c) P1, P2, P3…. Pn(Q (R1 ⋈ R2 ⋈ R3⋈……⋈ Rm))
1 Ram 5 35
(d) P1, P2, P3…. Pn(Q (R1× R2 × R3×…… ×Rm)) 2 Shaym 9 22
3 Ramesh 10 19
[MCQ] 4 Suresh 3 NULL
3. Consider the following equivalencies between 5 Akhil NULL 35
expressions of relational algebra, each involving Reserves
relations A (P, Q) and B (R, S). Assume that there is SailID BoatID Date
no foreign key, A attribute to table can be NULL, all 1 4 2017-03-15
attributes are of integer types which of the following 1 5 2017-04-15
equivalencies is/are TRUE? 3 2 2014-04-15
(a)  P, Q (A×B) = A 4 4 2018-01-01
(b) A – T (P, Q) (B) = T (P, Q) (B – ( T (R, S) (A))) 5 1 2017-12-25
(c)  P, Q, S (A ⋈Q=R B) = A ⋈ (T(Q, S) (B)) Boats
(d) None of the above BoatID BoatName Color
1 Lake Red
[MCQ] 2 Fish Yellow
4. Let A = (P, Q, R) and a1 and a2 both be relations on 3 Clipper Green
schema A. Give on expression in the domain relation 4 Yatch Green
calculus List- I, match the List-I expression to its 5 Fish Yellow
equivalent relational algebra query in List-II.
6 Clipper red
2

[MSQ]
and the following relational algebra query. 9. Consider the following Database
BoatID (Age = 35  rating ≥ 5 (sailors) ⋈ Reserves) Tool (TooID, Brand, Price)
BoatID (Rating < 5 (Sailors)⋈Reserves) Jobsite (Location, compensation, Task)
The number of rows returned by the above query ToolBox(ToolBoxID, location)→location is a foreign
is . key to jobsite.
Holds(ToolBoxID, ToolID) →ToolBoxID is a foreign
[MCQ] key to ToolBox. ToolID is a foreign key to Tool.
6. Consider the relation schemas w(P, Q, R), x (S, P, T) And consider the following SQL query.
y(P, Q, R, S, T) and z (R, S, T). A query that uses SELECT DISTINCT T. ToolID
additional operators of relational algebra: FROM Tool T, Holds H, ToolBox B, Jobsite J
((w × x)  y) ÷ z.
WHERE T. ToolID = H.ToolId AND H.ToolBoxID =
What will be the result set if we write this query using
only the basic operators of relational algebra? B. ToolBoxID AND B. location = J. location AND J.
(a) Result set of the basic operator’s query will be Task = ‘welding’
greater than the result set of given query. Which of the following would be an equivalent
(b) Result set will only consist of attributes P and Q. relational algebra query?
(c) Some of the operations in query cannot be (a) ToolID (Tool ⋈ Holds ⋈ ToolBox ⋈ task =
performed due to incompatible relation schemas
‘welding’(jobsite))
(d) Query cannot be written by only using basic
operations. (b) ToolID (task = ‘welding’ (Tool ⋈ (Holds ⋈ Tool Box)
⋈ Jobsite)
[MSQ] (c)  task = ‘welding’ (ToolID (Tool) ⋈ Holds ⋈ Tool Box
7. Consider the following relational table A ⋈ Jobsite)
A (d) None of the above
P Q R S T
p1 q1 r1 s1 t1 [MSQ]
p2 q2 r2 s2 t2 10. Consider the following two relations A (P, Q) and
Also, consider the decomposition of the relation A into B (R, S). Which of the following statement is/are
relations A1 = (P, Q, R) and A2 = (R, S, T) which of the
TRUE?
following is/are correct based on the above relations.
(a) A1 (A) ⋈ A2 (A) =A (a) The cardinality of (A⋈P = R B) is always larger
(b) A1 (A) ⋈ A2 (A)  A than or equal to the size of (A⋈P = R and Q=S B).
(c) PQ →T is true in the table A1 (A) ⋈ A2 (A) (b) The cardinality of (A⋈P = R and Q  S B) is always
(d) None of the above larger than or equal to the size of (A⋈P = R and Q = S
B).
[MSQ] (c) These two-expression (P = 5 (A⋈Q=RB)) and (P =
8. Which of the following relational algebra expression
5 (A) ⋈Q=R B) are always equivalent.
is/are always holds correct?
(d) These two expressions (A × B) – (A ⋈ Q = R B) and
(a) (X ⋈ Y) ⋈Z = (Z ⋈ X) ⋈ Y
(b) A (B (X)) = B (A (X) (A⋈Q  R B) are always equivalent.
(c) A (B (X)) = B (A (X)
(d) None of the above
3

Answer Key
1. (d) 7. (a, c)
2. (d) 8. (a, b)
3. (c) 9. (a, b)
4. (a) 10. (a, c, d)
5. (1)
6. (c)
4

Hints & Solutions


1. (d) U: σ rating<5 (Sailors) ⋈ Reserves
In relational algebra A ÷ B is defined as P(A) –P
((P(A)× qr (B) – p,q,r (A)) 4 Suresh 3 NULL 4 2018-01-01
A÷ B is used when we wish to express queries with π BoatID (S) ⋂ π BoatID(u) = {4, 5} ⋂ {4} = {4}
“all”.

2. (d) 6. (c)
SELECT DISTINCT P1, P2, P3 …. Pn Given:
w (P, Q, R), x (S, P, T) y(P, Q, R, S, T) and z (R, S, T)
FROM R1, R2, R3….. Rm
(w × x) contains 6 attributes whereas y contains 5
WHERE Q attributes. So, they aren’t union-compatible. Hence
So, from R1, R2, R3…. Rm intersection operation can’t be performed.
Here, there is no join condition, so it will perform NOTE: If number of attributes in Relation A is n and
cartesian product, then select Q and perform number of attributes in relation B is m then number of
projection. attributes “A x B” will be “n + m”.
P1, P2, P3…. Pn (Q (R1× R2 × R3×…… ×Rm))
7. (a, c)
(a) TRUE
3. (c)
(a) When B = , then result of A × B = then it is not A
equivalent to A. So, this equivalence is false. P Q R S T
(b) It is clearly seen that it is false / not equivalence p1 q1 r1 s1 t1
as difference is not commutative. p2 q2 r2 s2 t2
(c) Both expressions are equivalent. In expression
A⋈T(Q, S) (B), first we are performing rename A1(A) A2(A)
P Q R R S T
operation on attribute of relation B and then
p1 q1 r1 r1 s1 t1
performing natural join on common column Q. p2 q2 r2 r2 s2 t2

4. (a) A1(A) ⋈A2(A)


a1  a2 = {< p, q, r > | < p,q,r > a1 < p, q, r > a2} P Q R S T
a1  a2 = {< p, q, r > | < p,q,r > a1  < p, q, r > a2} p1 q1 r1 s1 t1
a1 – a2 = {< p, q, r > | < p,q,r > a1  < p, q, r > a2} p2 q2 r2 s2 t2
A1(A) ⋈A2(A) = A
5. (1) (b) FALSE since A1(A) ⋈A2(A) = A
Let σ age = 35  rating ≥ 5 (sailors) as T
(c) TRUE. PQ→T holds in A1(A) ⋈A2(A). An FD
T: 1 Ram 5 35
PQ→T holds if and only iff- for same values of
is selected. PQ, the T value must be same.
(5, Akhil, Null, 35) is not selected as rating contains
NULL value and NULL cannot be compared to ‘5’.
8. (a, b)
NOTE: Null compared with value result will be
(a) Natural join is commutative and Associative so it
undefined. is always true.
S: T ⋈ Reserves (b) Selection is commutative.
(c) Projection is not commutative.
Sail Sail Rating Age Boat ID Date Hence, a and b are correct.
ID Name
1 Ram 5 35 4 2017-03-15
2 Ram 5 35 5 2017-04-15
5

9. (a, b) (b) False, the cardinality of (A⋈P = R and Q  S B) is


(a) Task = ‘welding’ (Jobsite) always larger than or equal to the size of (A⋈P = R
From this we will get all row of jobsite having task and Q = S B).
welding.
(c) True, because the results of both (P=5 (A⋈Q=R B))
Tool ⋈ holds ⋈ Tool Box ⋈ Jobsite
Natural join is done and with ToolID→ ToolID and (P=5 (A) ⋈Q=R B) are always equivalent.
column gets displayed. (d) True because the result (A×B) – (A⋈ Q = RB) and
(b) same explanation as (A) (A ⋈Q  R B) are always equivalent.
(c) incorrect because after projecting ToolID we Hence, correct answer is a, c and d.
cannot apply condition on task.
Hence corrects option is a and b.

10. (a, c, d)
(a) True, because (A⋈P=R and Q=S B) is more restrictive
than (A⋈P = R B), it will also filter out the row in
which Q is not equal to S therefore the cardinality
(Number of rows) of (A ⋈P=R B) is always larger
than or equal to the size of (A⋈P = R and Q = S B).

Any issue with DPP, please report by clicking here:- https://forms.gle/t2SzQVvQcs638c4r5


For more questions, kindly visit the library section: Link for web: https://smart.link/sdfez8ejd80if

PW Mobile APP: https://smart.link/7wwosivoicgd4

You might also like