Is Cartesian Product same as Full Outer Join found in Relational Database SQL? I ask because I am taking a Discrete Mathematics course and I just want a better understanding of how what I am studying (Cartesian Product) applies to or maps to what I do when developing software (SQL Joins).


No: the Cartesian product is not the same as SQL FULL OUTER JOIN.

For example: if A = {1,2} and B = ∅, then A × B = {1,2} × ∅ = ∅, i.e. the Cartesian product yield the empty set. But, since FULL OUTER JOIN does not require each record in the two joined tables to have a matching record, if B is empty and A is not, FULL OUTER JOIN will still return some rows.

However, CROSS JOIN will return the Cartesian product of rows from tables in the join.

The link between is SQL and discrete mathematics is relational algebra (cf. Codd's theorem) if you want to check out more the maths behind SQL.

  • 2
    $\begingroup$ Excellent. Thank you very much Frank. $\endgroup$ – philologon Feb 8 '14 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.