Database Design (Examples)
Database Design (Examples)
Objective
The purpose of this assignment is to design and implement a relational database for managing a
company's employees, departments, projects, and employee project assignments using MySQL.
By the end of the assignment, you should be able to:
Design a database named CompanyDB that stores data for employees, departments, projects,
and employee assignments. The following structure outlines the requirements for each table:
Table 1: Employees
This table stores information about company employees. Each employee has the following
attributes:
Table 2: Departments
This table stores information about the various departments in the company:
department_id: Unique identifier for each department (Primary Key, Auto Increment).
department_name: Name of the department.
location: Location of the department.
Table 3: Projects
project_id: Unique identifier for each project (Primary Key, Auto Increment).
project_name: The name of the project.
start_date: The project’s start date.
end_date: The project’s expected or actual end date.
Table 4: Assignments
This table represents the relationship between employees and projects (many-to-many). Each
employee can be assigned to multiple projects, and each project can have multiple employees.
assignment_id: Unique identifier for each assignment (Primary Key, Auto Increment).
employee_id: The employee assigned to the project (Foreign Key to Employees table).
project_id: The project the employee is assigned to (Foreign Key to Projects table).
assigned_date: The date the employee was assigned to the project.
role: The employee's role on the project.
Write and execute SQL commands to create the four tables described above. Use appropriate
data types for each field. Include Primary Keys and Foreign Keys where necessary.
Insert data into the Departments, Employees, Projects, and Assignments tables. Use INSERT
INTO SQL statements to populate these tables with sample data.
Write SQL queries to retrieve and manipulate data from the database.
Ensure the database is normalized to at least the Third Normal Form (3NF):
1NF: Each table has atomic (indivisible) values, with no repeating groups.
2NF: All non-key attributes are fully dependent on the primary key.
3NF: No transitive dependencies (non-key attributes should not depend on other non-key
attributes).