Database Administration lab 3 (1)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Database Administration & Management Lab 02

Tasks

Muhammad Abdullah
F2022105208

Lab Task:

Scenario: Imagine you’re working with a company database that stores information about
employees and their departments. Based on this scenario, perform the following queries
to retrieve
and analyze data: [CLO1, CLO2, CLO3] (10)

1. Write a SQL Query to create a database Company_DB.

2. Write a SQL query to create a table named Departments with the following columns:
• Department_ID (integer, primary key)
• Dep_Name (string, up to 50 characters)

3. Write a SQL query to create a table named Employees with the following columns:
• Employee_ID (integer, primary key)
• Name (string, up to 50 characters)
• Department_ID(integer, foreign key)

4. Write a query to Insert values in both Tables.

5. Write a SQL query to Select all employee names and their respective department
names.
6. Write a SQL query to display a list of all employees, including those without a
department.

7. Write a SQL query to list all departments and the employees assigned.

8. Write a SQL query to list all employees and all departments, even if they don’t match.
9. Find employees who are not assigned to any department.

10. List all departments without any employees assigned.


11. List the names of employees working in the IT department.

12. Count the number of employees in each department.

13. Write an SQL query to list all employees and their department names, ordered by the
department name.

You might also like