You are on page 1of 8

Sir Syed University of Engineering & Technology (SSUET)

Software Engineering Department


Sir Syed University of Engineering &Technology, Karachi
Main University Road, Karachi 75300
http://www.ssuet.edu.pk

Assignment # 03

Course: Introduction Database Management System (SWE-209)

M. Shahbaz Alam (2020-SE-023)


Samana Kazim (2020-SE-034)
M. Talha Rehman (2020-SE-004)
Fabayha Tahir(2020-SE-044)

Section: “A”
Semester: 4th

Course Instructor Name: Sir Ali Yousuf Khan


Index

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.

The relational schema for the ER Diagram is given below as:

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

Student: Program: Course:


GivenNames Name Name
Surname Program_id PK P_ID FK
Student_ID PK CreditPoints CreditPoints
Date-of_Birth YearCommenced YearCommenced
YearEnrolled Course_id PK/FK
P_ID FK

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.

In Generalization, size of schema gets reduced. In Specialization, size of schema gets


increased.

There is no inheritance in Generalization. There is inheritance in Specialization.

Example of Generalization: Example of Specialization:


Consider two entities Student and Patient. Consider an entity Account. This will have
These two entities will have some some attributes consider them Acc_No and
characteristics of their own. For example Balance. Account entity may have some other
Student entity will have Roll_No, Name and attributes like Current_Acc and Savings_Acc.
Mob_No while patient will have PId, Name Now Current_Acc may have Acc_No, Balance
and Mob_No characteristics. Now in this and Transactions while Savings_Acc may have
example Name and Mob_No of both Student Acc_No, Balance and Interest_Rate henceforth
and Patient can be combined as a Person to we can say that specialized entities inherits
form one higher level entity and this process is characteristics of higher level entity.
called as Generalization Process.

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

Department: Course: Instructor:


DepartmentName PK Course_ID PK Instuctor_ID PK
Location Duration Phone
I_ID FK Course_name First_name
D_Name FK Last_name
I_ID PK/FK D_Name FK

Student:
Student_ID PK EnrolledBy:
first_name C_ID PK/FK
last_name S_ID PK/FK
phone

6|Page

You might also like