Lecture 4 - Joins Flashcards

1
Q

What is an inner join?

A

A condition that matches FK and PKs in SQL?

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

What is EQUIJOIN?

A

it is another name for inner join

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

Example of inner / equi join.

A

SELECT firstname , lastname, address
FROM (EMPLOYEE JOIN DEPARTMENT ON Dno = Dnumber)

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

Unusual syntax example of inner join

A

SELECT Fname, Lname, Address
FROM EMPLOYEE, DEPARTMENT
WHERE Dname = ‘Research’ %selection condition
AND DNO = DNUMBER; %equi-join condition

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

Inner join only works when …

A

there is a matching tuple i.e. FK is not null

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

What is an outer join?

A

joining on attributes but includes NULLs

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

What is an outer left join?

A

LEFT OUTER JOIN (LR LEFT OUTER JOIN RR)
- Every tuple in the left relation LR must appear in result
- If no matching tuple exists, just add NULL values for attributes of
right relation RR

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

What is an outer right join?

A

RIGHT OUTER JOIN (LR RIGHT OUTER JOIN RR)
- Every tuple in the right relation RR must appear in result
- `If no matching tuple exists, just add NULL values for attributes of left
relation LR

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

Example of left outer join?

A

SELECT E.Lname, S.Lname
FROM (EMPLOYEE AS E LEFT OUTER JOIN EMPLOYEE AS S
ON E.Super_SSN = S.SSN)

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

What is this doing:

SELECT E.Fname, E.Minit, E.Lname, D.Dname
FROM EMPLOYEE AS E LEFT OUTER JOIN DEPARTMENT AS D
ON E.SSN = D.MGR_SSN

A

We are getting all employees and what department they’re in charge of if any (NULL if not)

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

With joins, do NULL values represent uncertainity or certainity?

A

Certainity, we know the context i.e. employee has no supervisor or employee is not a department manager

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