Lecture 8 Flashcards
How to do Cartesian product of relations R and S using SQL?
SELECT * FROM R, S;
How to do Theta-Join using SQL?
SELECT * FROM R, S WHERE R.E = S.E;
How to create alias of table name in SQL?
FROM R AS R1
What are the operators for union, intersection and difference in SQL?
UNION, INTERSECT, and EXCEPT (note MySQL does not support INTERSECT and EXCEPT and UNION drops duplicates, but UNION ALL does not).
How to do a subquery in SQL?
Just put query between brackets, and include it in the FROM statement.
How to test if R is not empty?
EXISTS R
How to do join in SQL?
After FROM A JOIN B on A.a = B.a
How to do outer join in SQL? And left and right?
FULL OUTER JOIN, not supported in MySQL, so there we create the UNION of the following(if you do not care about duplicates).
LEFT OUTER JOIN and RIGHT OUTER JOIN