Dbms Exp6
Dbms Exp6
EXPERIMENT NUMBER: 6
AIM: Implement various Join operations.
OBJECTIVES: Efficiently merge data from multiple tables using different JOIN types to
ensure accurate, optimized, and meaningful query results.
THEORY: In SQL, joins are used to combine rows from two or more tables based on a
related column between them. The basic idea behind joins is that relational databases store
data across multiple tables to maintain efficiency, structure, and data integrity. Joins allow
you to combine this data to retrieve meaningful results by relating the data from different
tables.
Types of Joins:
1. Natural Join
i) Purpose: A NATURAL JOIN automatically joins tables based on all columns with
the same name in both tables. It eliminates duplicate columns from the result.
ii) Syntax: SELECT [column1, column2, ...] FROM table1 NATURAL JOIN table2;
ii) Syntax: SELECT [column1, column2, ...] FROM table1 JOIN table2 ON
table1.common_column = table2.common_column;
ii) Syntax: SELECT [column1, column2, ...] FROM table1 LEFT JOIN table2 ON
table1.common_column = table2.common_column;
ii) Syntax: SELECT [column1, column2, ...] FROM table1 RIGHT JOIN table2 ON
table1.common_column = table2.common_column;
iii) Example: SELECT employees.name, departments.department_name FROM
employees RIGHT JOIN departments ON employees.department_id =
departments.department_id;
CONCULSION: In this experiment, we explored the use of different SQL JOIN types to
efficiently merge data from multiple tables, with a focus on ensuring accurate, optimized,
and meaningful query results.
OUTPUT: