LO: To differentiate the various types of table joins.
To execute table joins using suitable join types.
To interpret the output for a given query. SUCCESS CRITERIA
Cross Join: A Cross Join returns the Cartesian product of two tables, combining each row of the
To explain the purpose
first table with every row of the second. It is used when all possible combinations of the rows
of joins.
are needed, often resulting in a large number of rows.
Equi Join: An Equi Join retrieves rows from two or more tables based on a matching column
using the equality operator (=). It requires specifying the join condition explicitly using a WHERE To list the key
or ON clause. differences between
the types of joins.
Natural Join: A Natural Join automatically joins tables based on columns with the same name
and compatible data types. It eliminates duplicate columns in the result and does not require To write sql queries
specifying the join condition. using table joins.
To predict the output
for a given join query.
CROSS JOIN
Returns all possible combinations of records.
Degree of cross joined table is the sum of degrees of individual table.
SELECT * FROM SENDER,RECEIVER;
Cardinality of cross joined table is the product of cardinalities of individual table.
SELECT * FROM SENDER JOIN RECEIVER;
EQUI JOIN
Combines records from multiple table based on common columns.
SELECT * FROM SENDER,RECEIVER WHERE
SENDER.S_ID = RECEIVER.S_ID;
SELECT * FROM SENDER JOIN RECEIVER ON
SENDER.S_ID = RECEIVER.S_ID;
NATURAL JOIN
Combines records from multiple table based on common
columns eliminating the duplicate columns in the output table.
SELECT S.S_ID,R.R_CITY FROM SENDER S,
RECEIVER R WHERE S.S_ID = R.S_ID;
SELECT S.S_ID,R.R_CITY FROM SENDER S
NATURAL JOIN RECEIVER R;