0% found this document useful (0 votes)
14 views

Assignment

Uploaded by

honeypriyanshi22
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Assignment

Uploaded by

honeypriyanshi22
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Ques on 2: Consider a university database that needs to store informa on about students, courses, and enrollments.

Perform the following tasks:

1. Iden fy the main en es and their a ributes.

Sol: En es:

 Student

 Course

 Enrollment (a rela onship en ty connec ng students and courses)

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

2. Define the primary keys for each en ty.


Student : StudentID

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)

3. Create an En ty-Rela onship (ER) diagram to represent the data model.


Ques on 3: Given the following scenario, create an Enhanced En ty-Rela onship (EER) diagram: A company database needs to store informa on about employees, where each employee
can be a full- me employee, a part- me employee, or a contractor. Full- me employees have benefits such as health insurance and pension plans. Part- me employees have hourly
wages, and contractors have contract details including start and end dates. Include specializa on/generaliza on in your EER diagram and explain your design choices.

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.

Course Table Structure


Column Name Data Type Constraints Descrip on
CourseID INTEGER Primary Key, NOT NULL Unique iden fier for each course.
CourseName VARCHAR(100) NOT NULL The name of the course.
CourseDescrip on TEXT A brief descrip on of the course.
Credits INTEGER NOT NULL The number of credits for the course.

3. Enrollment Table Structure


Column Name Data Type Constraints Descrip on
EnrollmentID INTEGER Primary Key, NOT NULL Unique iden fier for each enrollment record.
StudentID INTEGER Foreign Key, NOT NULL References Student(StudentID).
CourseID INTEGER Foreign Key, NOT NULL References Course(CourseID).
EnrollmentDate DATE NOT NULL The date the student enrolled in the course.
Grade CHAR(2) The grade received by the student in the course.

CREATE TABLE Student (


StudentID INTEGER PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DateOfBirth DATE,
Email VARCHAR(100),
PhoneNumber VARCHAR(20),
Address VARCHAR(200)
);

CREATE TABLE Course (


CourseID INTEGER PRIMARY KEY,
CourseName VARCHAR(100),
CourseDescrip on TEXT,
Credits INTEGER
);

CREATE TABLE Enrollment (


EnrollmentID INTEGER PRIMARY KEY,
StudentID INTEGER,
CourseID INTEGER,
EnrollmentDate DATE,
Grade CHAR(2),
FOREIGN KEY (StudentID) REFERENCES Student(StudentID),
FOREIGN KEY (CourseID) REFERENCES Course(CourseID)
);

You might also like