This repository contains a database called CompanyDB. The database stores data about a company’s employees, departments, projects, and customers — along with their relationships and associated details.
The CompanyDB database models a company’s employees, departments, projects, and customer relationships. It ensures consistent and secure storage of data while maintaining accurate connections between different organizational units.
This repository includes the following components related to the database design:
Entity–Relationship Diagram:
The diagram above visualizes the relationships and structure between the database tables.
Database Tables:
The file Database-Tables.xlsx contains all database tables, filled with sample data to enhance clarity and readability. Additional supporting tables used to establish relational structures are also included in this file.
* The first and underlined columns in each table represent the primary key fields.
* The columns highlighted in orange indicate foreign key fields
Database Creation Script:
The file DatabaseScript.sql contains SQL code for creating the database.
⚠️ Note: The script is specifically designed to run on MySQL
-
The Employees table is related to the Departments table through
DepartmentID, forming a one-to-many (1–N) relationship. -
The Employees table is related to the Offices table through
OfficeID, forming a one-to-many (1–N) relationship. -
The Employees table is related to the Projects table through
ProjectID, forming a one-to-many (1–N) relationship. -
The Customers table is related to the Orders table through
CustomerID, forming a one-to-many (1–N) relationship. -
The Departments and Customers tables are related through both
DepartmentIDandCustomerID, forming a many-to-many (N–N) relationship. This relationship is implemented via a junction table named Department-Customer. -
The Products and Customers tables are related through both
ProductIDandCustomerID, forming a many-to-many (N–N) relationship. This relationship is implemented via a junction table named Customer-Product.
To create the database locally:
- Clone the repository to your computer.
- Open the DatabaseScript.sql file in
MySQL Workbenchand execute it to generate the database.
You can clone the project using the following command:
git clone https://github.com/bahadirverir/CompanyDatabaseDesign.git