Home » Database » Database miscellaneous » Question

Database miscellaneous

  1. Let R1 (A, B, C) and R2 (D, E) be two relational sachemas, where the primary keys are shown underlined, and let C be a foreign key in R1 referring to R2. Suppose there is no violation of the above referential integrity constraint in the corresponding relational instances r1 and r2 .Which one of the following relational algebra expressions would necessarily produce an empty relation?
    1. ΠD(r2) - ΠC(r1)
    2. ΠC(r1) - ΠD(r2)
    3. ΠD(r1C ≠ D(r2)
    4. ΠC(r1C = D(r2)
Correct Option: B

C is an attribute in R1 but D is a key in K2.
So consider ΠC (r1) – ΠD (r2)
So the result of this query would be all those tuples

which are in ΠC (r1) but not in ΠD (r2). Since D is a key so it has all the possible values of C. So difference would always be empty. Hence (b) is correct.



Your comments will be displayed only after manual approval.