0
0
DBMS Theoryknowledge~30 mins

Joins in SQL in DBMS Theory - Mini Project: Build & Apply

Choose your learning style9 modes available
Joins in SQL
📖 Scenario: You are working with two tables in a company's database: employees and departments. You want to learn how to combine data from these tables to see which employee works in which department.
🎯 Goal: Build SQL queries step-by-step to join the employees and departments tables using different types of joins.
📋 What You'll Learn
Create the employees table with exact columns and data
Create the departments table with exact columns and data
Write a SQL query using INNER JOIN to combine employees with their departments
Write a SQL query using LEFT JOIN to include all employees even if they have no department
💡 Why This Matters
🌍 Real World
Joining tables is a common task in databases to combine information like employee details with their department names.
💼 Career
Understanding SQL joins is essential for data analysts, database administrators, and developers to query and report data effectively.
Progress0 / 4 steps
1
Create the employees table with data
Write SQL statements to create a table called employees with columns id (integer), name (text), and department_id (integer). Insert these exact rows: (1, 'Alice', 10), (2, 'Bob', 20), (3, 'Charlie', NULL).
DBMS Theory
Need a hint?

Use CREATE TABLE to define the table and INSERT INTO to add rows.

2
Create the departments table with data
Write SQL statements to create a table called departments with columns id (integer) and name (text). Insert these exact rows: (10, 'HR'), (20, 'Engineering'), (30, 'Marketing').
DBMS Theory
Need a hint?

Use the same pattern as the employees table to create departments.

3
Write an INNER JOIN query to combine employees with their departments
Write a SQL query that selects employees.name and departments.name as department using an INNER JOIN on employees.department_id = departments.id.
DBMS Theory
Need a hint?

Use INNER JOIN to combine rows where the department matches.

4
Write a LEFT JOIN query to include all employees even without a department
Write a SQL query that selects employees.name and departments.name as department using a LEFT JOIN on employees.department_id = departments.id to include employees without a department.
DBMS Theory
Need a hint?

Use LEFT JOIN to include all employees, even those without a matching department.