Q.a) Display all possible combinations of tuples of relations DANCE and MUSIC.
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →(a) "All possible combinations of tuples" is the Cartesian product — SELECT * FROM DANCE, MUSIC;. With DANCE (4 rows) and MUSIC (5 rows), it pairs every DANCE row with every MUSIC row: 4 × 5 = 20 rows (Table 9.23).
(b) Keeping only the pairs whose Name values agree turns that product into an equi-join — SELECT * FROM DANCE D, MUSIC M WHERE D.Name = M.Name;, giving the 2 rows of Table 9.24.
Concept understanding — product then selection
The join is not a primitive operation. It is built from two simpler ones:
| Operation | Symbol | Effect | Rows produced |
|---|---|---|---|
| Cartesian product | DANCE × MUSIC | pair every tuple of DANCE with every tuple of MUSIC | m × n |
| Selection on the product | σ<sub>condition</sub> | keep only the pairs that satisfy the condition | ≤ m × n |
| Equi-join | DANCE ⋈<sub>Name = Name</sub> MUSIC | the two above, combined | usually far fewer |
So an equi-join is σ<sub>DANCE.Name = MUSIC.Name</sub>(DANCE × MUSIC). Part (a) builds the raw material; part (b) filters it.
The relations from the textbook (Section 9.10.1)
Table 9.18: DANCE
| SNo | Name | Class |
|---|---|---|
| 1 | Aastha | 7A |
| 2 | Mahira | 6A |
| 3 | Mohit | 7B |
| 4 | Sanjay | 7A |
Table 9.19: MUSIC
| SNo | Name | Class |
|---|---|---|
| 1 | Mehak | 8A |
| 2 | Mahira | 6A |
| 3 | Lavanya | 7A |
| 4 | Sanjay | 7A |
| 5 | Abhay | 8A |
DANCE has degree 3, cardinality 4. MUSIC has degree 3, cardinality 5.
(a) All possible combinations — the Cartesian product
mysql> SELECT * FROM DANCE, MUSIC;
DANCE X MUSIC has degree 3 + 3 = 6 and cardinality 4 × 5 = 20 — exactly Table 9.23, which the textbook itself points to as the answer to part (a):
Table 9.23: DANCE X MUSIC
| SNo | Name | Class | SNo | Name | Class |
|---|---|---|---|---|---|
| 1 | Aastha | 7A | 1 | Mehak | 8A |
| 2 | Mahira | 6A | 1 | Mehak | 8A |
| 3 | Mohit | 7B | 1 | Mehak | 8A |
| 4 | Sanjay | 7A | 1 | Mehak | 8A |
| 1 | Aastha | 7A | 2 | Mahira | 6A |
| 2 | Mahira | 6A | 2 | Mahira | 6A |
| 3 | Mohit | 7B | 2 | Mahira | 6A |
| 4 | Sanjay | 7A | 2 | Mahira | 6A |
| 1 | Aastha | 7A | 3 | Lavanya | 7A |
| 2 | Mahira | 6A | 3 | Lavanya | 7A |
| 3 | Mohit | 7B | 3 | Lavanya | 7A |
| 4 | Sanjay | 7A | 3 | Lavanya | 7A |
| 1 | Aastha | 7A | 4 | Sanjay | 7A |
| 2 | Mahira | 6A | 4 | Sanjay | 7A |
| 3 | Mohit | 7B | 4 | Sanjay | 7A |
| 4 | Sanjay | 7A | 4 | Sanjay | 7A |
| 1 | Aastha | 7A | 5 | Abhay | 8A |
| 2 | Mahira | 6A | 5 | Abhay | 8A |
| 3 | Mohit | 7B | 5 | Abhay | 8A |
| 4 | Sanjay | 7A | 5 | Abhay | 8A |
20 rows in set.
Degree of DANCE × MUSIC = degree(DANCE) + degree(MUSIC) = 3 + 3 = 6
Cardinality = cardinality(DANCE) × cardinality(MUSIC) = 4 × 5 = 20
Most of these 20 rows are meaningless — "Aastha danced and Mehak sang" is not a fact about anybody. Only two of the 20 pairs (row 6 and row 16 above) have matching names — those are exactly the two rows part (b) isolates. A Cartesian product on real tables can explode fast: 1,000 rows × 1,000 rows gives a million rows. Omitting the join condition by mistake is exactly how a query accidentally becomes a Cartesian product.
(b) Keeping only the rows where Name matches — the equi-join
mysql> SELECT * FROM DANCE D, MUSIC M WHERE D.Name = M.Name;
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.