Design and Implementation Assignment
Objective: Design a complete Entity-Relationship (ER) diagram for a company database using MySQL Workbench based on the specifications provided below.
Design a comprehensive database system for a company that manages employees, departments, projects, and their relationships. The system should track employee information, departmental structure, project assignments, work hours, dependents, and supervisory relationships.
| Attribute | Type | Constraints | Description |
|---|---|---|---|
| Dnumber | INT | Primary Key | Unique department number |
| Dname | VARCHAR(50) | NOT NULL, Unique | Department name |
| Mgr_ssn | CHAR(9) | Foreign Key | Manager's SSN (references EMPLOYEE) |
| Mgr_start_date | DATE | Date when manager started | |
| Locations | Multi-valued | Separate table needed | Department office locations |
| Attribute | Type | Constraints | Description |
|---|---|---|---|
| SSN | CHAR(9) | Primary Key | Social Security Number |
| Fname | VARCHAR(30) | NOT NULL | First name |
| Lname | VARCHAR(30) | NOT NULL | Last name |
| Address | VARCHAR(100) | Employee address | |
| Salary | DECIMAL(10,2) | Employee salary | |
| Sex | CHAR(1) | CHECK (Sex IN ('M', 'F')) | Gender |
| Bdate | DATE | Birth date | |
| Dno | INT | Foreign Key, NOT NULL | Department number (references DEPARTMENT) |
| Super_ssn | CHAR(9) | Foreign Key | Supervisor's SSN (self-referencing) |
| Attribute | Type | Constraints | Description |
|---|---|---|---|
| Pnumber | INT | Primary Key | Unique project number |
| Pname | VARCHAR(50) | NOT NULL, Unique | Project name |
| Plocation | VARCHAR(50) | Project location | |
| Dnum | INT | Foreign Key, NOT NULL | Controlling department number |
| Attribute | Type | Constraints | Description |
|---|---|---|---|
| Essn | CHAR(9) | Primary Key, Foreign Key | Employee SSN (references EMPLOYEE) |
| Dependent_name | VARCHAR(30) | Primary Key | Name of the dependent |
| Sex | CHAR(1) | CHECK (Sex IN ('M', 'F')) | Gender of dependent |
| Bdate | DATE | Birth date of dependent | |
| Relationship | VARCHAR(20) | Relationship to employee |
Cardinality: N:1
Description: Each employee works for exactly one department, but each department can have many employees.
Implementation: Foreign key Dno in EMPLOYEE table
Cardinality: 1:1
Description: Each department is managed by exactly one employee, and each employee can manage at most one department.
Implementation: Foreign key Mgr_ssn in DEPARTMENT table
Cardinality: 1:N
Description: Each department controls many projects, but each project is controlled by exactly one department.
Implementation: Foreign key Dnum in PROJECT table
Cardinality: M:N
Description: Employees can work on multiple projects, and projects can have multiple employees.
Attribute: Hours (number of hours worked)
Implementation: Separate WORKS_ON table with composite key (Essn, Pno)
Cardinality: 1:N
Description: Each employee can have multiple dependents, but each dependent belongs to exactly one employee.
Implementation: Foreign key Essn in DEPENDENT table
Cardinality: 1:N (Recursive)
Description: Each employee can supervise multiple employees, but each employee has at most one supervisor.
Implementation: Foreign key Super_ssn in EMPLOYEE table
| Criteria | Points | Description |
|---|---|---|
| Entity Design | 25 | Correct entities with all specified attributes and data types |
| Primary Keys | 15 | Proper identification and implementation of primary keys |
| Relationships | 25 | Correct implementation of all relationships with proper cardinalities |
| Foreign Keys | 15 | Proper implementation of foreign key constraints |
| Special Cases | 10 | Multi-valued attributes, recursive relationships, associative entities |
| Presentation | 10 | Clear diagram layout, proper naming conventions, documentation |
Upon completion of this lab assignment, students will be able to: