Lecture 8 Flashcards

1
Q

How to do Cartesian product of relations R and S using SQL?

A

SELECT * FROM R, S;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to do Theta-Join using SQL?

A

SELECT * FROM R, S WHERE R.E = S.E;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to create alias of table name in SQL?

A

FROM R AS R1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the operators for union, intersection and difference in SQL?

A

UNION, INTERSECT, and EXCEPT (note MySQL does not support INTERSECT and EXCEPT and UNION drops duplicates, but UNION ALL does not).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to do a subquery in SQL?

A

Just put query between brackets, and include it in the FROM statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to test if R is not empty?

A

EXISTS R

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to do join in SQL?

A

After FROM A JOIN B on A.a = B.a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to do outer join in SQL? And left and right?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly