Bird
0
0

In PostgreSQL, what is the effect of executing a CROSS JOIN between two tables students and classes?

easy📝 Conceptual Q1 of 15
PostgreSQL - Joins in PostgreSQL
In PostgreSQL, what is the effect of executing a CROSS JOIN between two tables students and classes?
AIt returns rows from the first table with NULLs for the second table.
BIt returns only rows where the student is enrolled in the class.
CIt returns rows where the student and class IDs match.
DIt returns all possible combinations of rows from both tables.
Step-by-Step Solution
Solution:
  1. Step 1: Understand CROSS JOIN

    A CROSS JOIN produces the Cartesian product of two tables, combining each row of the first table with every row of the second.
  2. Step 2: Apply to students and classes

    Every student will be paired with every class, regardless of enrollment.
  3. Final Answer:

    It returns all possible combinations of rows from both tables. -> Option D
  4. Quick Check:

    Number of rows = rows in students x rows in classes [OK]
Quick Trick: CROSS JOIN returns all row combinations [OK]
Common Mistakes:
  • Confusing CROSS JOIN with INNER JOIN
  • Expecting filtering conditions in CROSS JOIN
  • Assuming matching keys are required

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes