Assignment
Assignment
Sol: En es:
Student
Course
A ributes:
Student
StudentID (Primary Key)
FirstName
LastName
DateOfBirth
Email
PhoneNumber
Address
Course:
CourseID (Primary Key)
CourseName
CourseDescrip on
Credits
Enrollment
EnrollmentID (Primary Key)
StudentID (Foreign Key, references Student)
CourseID (Foreign Key, references Course)
EnrollmentDate
Grade
Course : CourseID
Enrollment: EnrollmentID (Composite key of StudentID and CourseID could also be considered, but we
are using EnrollmentID as the primary key for simplicity)
1. En es:
o Employee: A general en ty that stores common a ributes for all employees.
o Full-Time Employee, Part-Time Employee, and Contractor: These are specialized en es that inherit from the general Employee en ty.
2. A ributes:
o Employee: A ributes that are common to all types of employees, such as EmployeeID, Name, and Address.
o Full-Time Employee: Specific a ributes like HealthInsurance and PensionPlan.
o Part-Time Employee: Specific a ribute like HourlyWage.
o Contractor: Specific a ributes like ContractStartDate and ContractEndDate.
3. Specializa on/Generaliza on:
o This scenario involves a Generaliza on process where the general en ty Employee is specialized into Full-Time Employee, Part-Time Employee, and Contractor.
o This is a total specializa on, meaning every employee must be one of these subtypes.
EER Diagram Explana on
Employee (Superclass):
o A ributes: EmployeeID (PK), Name, Address
o Generalizes into:
Full-Time Employee (Subclass): EmployeeID (FK), HealthInsurance, PensionPlan
Part-Time Employee (Subclass): EmployeeID (FK), HourlyWage
Contractor (Subclass): EmployeeID (FK), ContractStartDate, ContractEndDate
Constraints:
o Total Par cipa on: Each employee must be classified as either a full- me employee, part- me employee, or contractor.
o Disjointness: An employee can only be one of these types at a me (i.e., an employee cannot be both a full- me employee and a contractor simultaneously).
Ques on 4: Consider a project management database where each project has mul ple tasks, and each task can have mul ple subtasks. Addi onally, each project is managed by a team of
employees.
Perform the following tasks:
1. Iden fy the main en es and their a ributes.
2. Create an ER or EER diagram that includes aggrega on and composi on to represent this scenario. Explain how aggrega on and composi on are used in your diagram.
Sol :
Main en es and their a ributes
Project
ProjectID (PK)
ProjectName
StartDate
EndDate
Budget
Task
TaskID (PK)
TaskName
StartDate
EndDate
Status
Subtask
SubtaskID (PK)
SubtaskName
StartDate
EndDate
Status
Employee
EmployeeID (PK)
EmployeeName
Posi on
Explana on of Aggrega on and Composi on:
Aggrega on: Aggrega on is used when a rela onship between en es is treated as a single en ty. In this scenario, a team manages a project, and this management rela onship can be
treated as an en ty by itself.
Composi on: Composi on is a strong form of associa on where a part (e.g., a task) cannot exist without the whole (e.g., the project). In this scenario, tasks and subtasks are parts of projects
and tasks, respec vely.
Ques on 5: Mapping ER/EER to Rela onal Model (10 marks)
Take the ER diagram you created in Ques on 2 or the EER diagram in Ques on 3, and perform the following tasks:
1. Map the en es and rela onships to rela onal tables.
2. Define the primary keys for each table
Student Table Structure
Column Name Data Type Constraints Descrip on
StudentID INTEGER Primary Key, NOT NULL Unique iden fier for each student.
FirstName VARCHAR(50) NOT NULL The first name of the student.
LastName VARCHAR(50) NOT NULL The last name of the student.
DateOfBirth DATE NOT NULL The birth date of the student.
Email VARCHAR(100) UNIQUE, NOT NULL The email address of the student.
PhoneNumber VARCHAR(20) The contact number of the student.
Address VARCHAR(200) The residen al address of the student.