Skip to content
Worked Examples · Example 1.7

Q.Using the DANCE and MUSIC relations to understand how two relations are used together in a query:

(a) Display all possible combinations of tuples of the relations DANCE and MUSIC (the Cartesian product). State the degree and cardinality of the resulting table.
(b) From all possible combinations of tuples of DANCE and MUSIC, display only those rows where the attribute Name in both relations has the same value (use table aliases D for DANCE and M for MUSIC).
Odisha ChseTextbookSubjective· 3mImportance★★★★★
33% · 13/40 Questions
🔒 Locked · start free trial →

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 →

Part (a) is the raw Cartesian product SELECT * FROM DANCE, MUSIC (degree 6, cardinality 20); part (b) filters it down with a WHERE condition comparing the aliased Name columns.

This is a code/query task on two small tables:

DANCE (degree 3, cardinality 4) — SNo, Name, Class: Aastha/7A, Mahira/6A, Mohit/7B, Sanjay/7A.

MUSIC (degree 3, cardinality 5) — SNo, Name, Class: Mehak/8A, Mahira/6A, Lavanya/7A, Sanjay/7A, Abhay/8A.

(a) Listing both tables in FROM, separated by a comma, with no join condition, produces the full Cartesian product — every DANCE row paired with every MUSIC row:

SELECT * FROM DANCE, MUSIC;

Degree = 3 + 3 = 6 (all columns from both tables, side by side). Cardinality = 4 × 5 = 20 (every combination). This is exactly Table 1.15 in the textbook.

(b) To keep only the rows that are actually related — where the same student name appears in both DANCE and MUSIC — add a WHERE condition. Since Name exists in BOTH tables, you must qualify it with a table alias to avoid ambiguity:

SELECT * FROM DANCE D, MUSIC M WHERE D.Name = M.Name;

D stands in for DANCE and M for MUSIC for the rest of this query. Checking each DANCE name against every MUSIC name: Mahira (in both, 6A) and Sanjay (in both, 7A) match; Aastha and Mohit don't appear in MUSIC at all. …

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.