3.5 Equijoins, self-joins, and cross-joins Flashcards

1
Q

What is the result of the following equijoin query?

SELECT Class.Name, Student.Name
FROM Class
INNER JOIN Student
ON Student.Code = Class.Code;
A

The INNER JOIN returns rows where Student.Code matches Class.Code.

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

What is the result of the following equijoin query?

SELECT Name, Address
FROM Buyer
LEFT JOIN Property
ON Price < MaxPrice;
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which join type is the following query?

A

Self-join

SELECT A.Name, B.Name
FROM EmployeeManager A
INNER JOIN EmployeeManager B
ON B.ID = A.Manager;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the following cross-join query result in?

SELECT Model, Gigabytes
FROM IPhone
CROSS JOIN Storage;
A

CROSS JOIN generates all combinations of IPhone models and storage capacities.

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

What is the result of the following query?

SELECT Student.Name
FROM Class
INNER JOIN Student
ON StudentGrade > AverageGrade
AND Student.Code = Class.Code;
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the primary use of equijoins?

A

To combine rows from tables where specified columns equal each other. Equijoins are typical for matching columns using the = operator.

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

Which SQL command combines two tables using conditions other than the equality operator?

A

Non-equijoin.

Non-equijoins utilize comparison operators other than =.

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

What does it mean when we refer to a ‘Cartesian product’ in SQL?

A

The result of a cross-join containing all possible row combinations. A Cartesian product pairs each row from the first table with every row from the second.

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

How do we distinguish same-table columns in a self-join?

A

Using aliases. Aliases act as prefixes to differentiate joined columns of the same table.

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

What is the result when using non-equijoin operators such as < and >?

A

Returns rows where the compare columns meet the specified non-equal condition.

Unlike equijoins, non-equijoins use operators like < or > instead of =.

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

Why are aliases necessary in self-joins?

A

To distinguish columns from the same tables. Aliases are used as prefixes to differentiate between the same table joined on itself.

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

Identify the join clause(s) usable in non-equijoin queries.

A

All JOIN clauses.

Non-equijoin conditions can apply with INNER, LEFT, RIGHT, or FULL JOINs.

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

What does a cross-join do without comparing columns?

A

Combines all rows from two tables into all possible pairs.

CROSS JOIN results in the Cartesian product of two tables.

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