Database Assignment 03
Database Assignment 03
Assignment # 03
Section: “A”
Semester: 4th
Page
S.No Headings
No
1. Question # 1: 1-2
Apply and map the following ER diagram to relational schema. Illustrate
the connectivity within relations (tables) through connecting lines.
2. Question # 2: 3-4
Define the following terminologies with examples.
• Specialization vs Generalization
• Total vs partial
• Disjoint vs overlap
3. Question # 3: 5-6
Apply and map the following ER diagram to relational schema. Illustrate
the connectivity within relations (tables) through connecting lines.
Question # 1:
Apply and map the following ER diagram to relational schema. Illustrate the connectivity
within relations (tables) through connecting lines.
Answer:
• Student is a strong entity, with an identifier, student_id, created to be the primary key used
to distinguish between students (remember, we could have several students with the same
name).
• Program is a strong entity, with the identifier program_id as the primary key used to
distinguish between programs.
• Each student must be enrolled in a program, so the Student entity participates totally in the
many-to-one Enrollsin relationship with Program. A program can exist without having any
enrolled students, so it participates partially in this relationship.
• A Course has meaning only in the context of a Program, so it’s a weak entity,
with course_id as a weak key. This means that a Course is uniquely identified using
its course_id and the program_id of its owning program.
• As a weak entity, Course participates totally in the many-to-one identifying relationship
with its owning Program. This relationship has Year and Semester attributes that identify its
sequence position.
1|Page
• Student and Course are related through the many-to-many Attempts relationships; a course
can exist without a student, and a student can be enrolled without attempting any courses, so the
participation is not total.
• When a student attempts a course, there are attributes to capture the Year and Semester, and
the Mark and Grade.
Student
GivenNames Surname Student_ID Date_of_Birth YearEnrolled P_ID
Program
Name Program_id CreditPoints YearCommenced
Course
Name P_ID CreditPoints YearCommenced Course id
Attempts
year Semester Mark Grade Std_ID C_ID
Attempts:
Year PK
Semester PK
Marks
Grade
Std_ID FK
C_ID FK
2|Page
Question # 2:
Define the following terminologies with examples.
• Specialization vs Generalization
• Total vs partial
• Disjoint vs overlap
Answer:
1. Specialization vs Generalization:
GENERALIZATION SPECIALIZATION
Generalization works in Bottom-Up approach. Specialization works in top-down approach.
3|Page
2. Total vs partial:
TOTAL PARTIAL
A sub-classing relationship is total if every A sub-classing relationship is partial if every
super-class entity is to be associated with some super-class entity is not necessary to be
sub-class entity associated with some sub-class entity
Total is represented using a double line Partial is represented using a single line
between the entity set and relationship set. between the entity set and relationship set.
Example: Example:
Double line between the entity set “Student” Single line between the entity set “Course” and
and relationship set “Enrolled in” signifies total relationship set “Enrolled in” signifies partial
participation. It specifies that each student must participation. It specifies that there might exist
be enrolled in at least one course. some courses for which no enrollments are
made.
3. Disjoint vs overlap:
DISJOINT OVERLAP
Disjoint means a subclass type patient can be The overlap rule forces a subclass (also known as a
either an outpatient or resident patient but not supertype instance) to have overlapping sets of
both. entities.
In disjoint, An entity can belong to not more In overlap, An entity can belong to more than
than one lower-level entity set. one lower-level entity set.
Example: Example:
4|Page
Question # 3:
Apply and map the following ER diagram to relational schema. Illustrate the connectivity
within relations (tables) through connecting lines.
Answer:
• Department is a strong entity, with an identifier, DepartmentName, created to be the primary
key used to distinguish between departments.
• Course is a strong entity, with the identifier Course_ID as the primary key used to distinguish
between courses.
• Each student must be enrolled in a course, so the Student entity participates totally in the many-
to-one Enrollsin relationship with course.
• A Course has meaning only in the context of a Program, so it’s a weak entity, with course_id as
a weak key. This means that a Course is uniquely identified using its course_id and
the program_id of its owning program.
5|Page
The relational schema for the ER Diagram is given below as:
Department
DepartmentName Location I_ID
Course
Course_ID Duration Course_name D_Name I_ID
Instructor
Instructor_ID phone first_name last_name D_Name
Student
Student_ID first_name last_name phone
EnrolledBy
C_ID S_ID
Student:
Student_ID PK EnrolledBy:
first_name C_ID PK/FK
last_name S_ID PK/FK
phone
6|Page