You are on page 1of 21

Lecture 4: E-R Diagrams

Instructor:Haya Sammaneh
E-R Diagram
Rectangle entity
Ellipse attribute
Diamond relationship
Double ellipse multi-valued attribute
Dashed ellipse derived attribute
Double line total participation (existence dependency)
Double rectangle weak entity
Double diamond relationships for weak entity
Composite attribute: consists of several components
Country
Employee
Address
Street
City
EmpNo
Name
Existence Dependence
The existence of an entity depends on the
existence of another entity

Customer
Loan
loan
borrow
CusNo
LoanNo
A loan cannot exist if
there is no borrower.
Weak Entities
A weak entity cannot be identified with its
own attributes
no key
A weak entity implies existence
dependency but NOT vice versa
LoanNo Amount Date_pay PaymentNo
Payment
A loan may have 240 payments, each identified by a payment
no 1 - 240.
The PaymentNo is unique given a particular loan but not
unique globally
PaymentNo is called partial key
The primary key of Payment is the combination of
LoanNo and PaymentNo.
Loan
payment
Amount
Loan
Ternary Relationship









Customer Loan Borrow
Branch
A customer
borrows a loan
from a branch.
Customer Loan Borrow
Branch
Issue
A customer borrows a
loan. A loan is issued
from a branch.
Exercise
A university registrars office maintains data
about the following entities:
a) courses, including number, title, credits, syllabus, and
prerequisites;
b) course offerings, including course number, year, semester,
section number, instructor(s), timings, and classroom;
c) students, including student-id, name, and program;
d) instructors, including identification number, name, department,
and title.
The enrollment of students in courses and grades awarded to
students in each course they are enrolled
Construct an E-R diagram for the registrars
office.
Entities
A university registrars office maintains data about the following entities:

(a) courses (b) course offerings (c) students (d) instructors
course
course-
offerings
student
instructor
Course
courses including number, title, credits,
syllabus, and prerequisites
Attribute?
Relationship?

prerequisite
maincourse
course_no
title
requires course
syllabus
credits
course offerings, including course
number, year, semester, section number,
instructor(s), timings, and classroom
Course Offering
time
room
course
section_no
semester
year
course-
offerings
is offered
course_no
Weak Entity
A weak entity can be identified uniquely only by
considering the primary key of another (owner) entity
Owner entity set and weak entity set must participate in
one-to-many relationships (one owner, many weak
entities).
Weak entity set must have total participation in th
identifying relationship set.
Difference between weak entity (WE)and existence
dependency(ED)
WE implies ED but not the other way round.
WE has only a partial key but ED may have a primary key
B
A
B
A
Student, Instructor
students, including student-id, name, and
program
instructors, including identification number,
name, department, and title
student
name sid
program
instructor
title
dept
name
iid
Enrollment
The enrollment of students in courses and
grades awarded to students in each course
they are enrolled
student
course-
offerings
enrols
grade
Anymore ?
Instructor teach course..
instructor teaches
course-
offerings
title
dept
name
iid
E-R diagram for a university.
prerequisite
maincourse
course_n
o
requires course
syllabus
credits
time
room
section_no
semeste
r
year
course-
offerings
is offered
enrols
grade
name sid
program
student instructor teaches
title
Exercise
Consider a database that records the grades of
students in different exams of different course
offerings.
a) assume that course offerings include time, room;
and can be identified uniquely by course_no,
semester, year, section_no.
b) students, including student-id, name, and program;
c) exam, including eid (optional), name, place, time.
Furthermore, grades of students in different exams of
course offerings must be modeled.
Construct an E-R diagram that models exams as
entities, and uses a ternary relationship, for the above
database.
E-R diagram for marks database.
student
sid
program
course-offerings
year
semester
time
room
section_no
takes
grade
exam eid
name place
time
course_no
name
Exercise
Construct an alternative E-R diagram that uses
only a binary relationship between students and
course-offerings.
Make sure that only one relationship exists
between a particular student and course-
offering pair, yet you can represent the marks
that a student gets in different exams of a
course offering.
semester
room
name
Another E-R diagram for marks database.
marks
student course-offerings
examof
takes
section_no year
exam
place
time
grade
sid
name course_no time
program
E-R Diagram for a Banking Enterprise

You might also like