Suppose we have a relational database with five tables: Table Key attributes S(sid, A) sid T(tid, B) tid U(uid, C) uid R(sid, tid, D) sid, tid…
Suppose we have a relational database with five tables:
| Table | Key attributes |
| S(sid, A) | sid |
| T(tid, B) | tid |
| U(uid, C) | uid |
| R(sid, tid, D) | sid, tid |
| Q(tid, uid, E) | tid, uid |
Here R implements a many-to-many relationship between the entities implemented with tables S and T, and Q implements a many-to-many relationship between the entities implemented with tables T and U.
(A) Write an SQL query that returns all records of the form sid, uid where sid is the key of an S-record and uid is the key of a U-record and these two records are related through the relations R and Q. Use SELECT and not SELECT DISTINCT in your query.
(B) Write an SQL query that returns records of the form A, C where the A-value is from an S-record and the C-value is from a U-record and these two records are related through the relations R and Q. Use SELECT and not SELECT DISTINCT in your query.
From the Combined Bank Assistant Programmer (CSE) June 2023 – Written exam, question 8 of 10.