Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

ER Model

Examples

Instructor: Ashok Singh Sairam


ashok@iitg.ac.in
Review (1)
• Entity – Real world distinguishable object Person Product

• Attributes – entity set has attributes name category


• domain of attributes price
• key/primary key Product

• Relationship – association between entities


• Degree
• Types
• Roles

MA 518: Database Management Systems 2


Review (2)
1 a Role:
One-to-one: 2
3
b
c
d

1 a

Many-to-one: 2
3
b
c
d

1 a
b
One-to-many:
2
3 c
d

1 a
Many-to-many: 2
3
b
c
d

MA 518: Database Management Systems 3


Review (3) Product makes Company

• Participation Constraints
Each product made by at most one company.
Some product made by no company?
• Weak Entity set
• identified uniquely by Product makes Company
considering the primary key of
another entity. Each product made by exactly one company
• Attribute of weak entity called

discriminator

MA 518: Database Management Systems 4


Example 1 (a)
• A university database contains information about professors (identified by social
security number, or SSN) and courses (identified by courseid). Professors teach
courses; each of the following situations concerns the Teaches relationship set.
For each situation, draw an ER diagram that describes it (assuming no further
constraints hold).
• Professors can teach the same course in several semesters, and each offering
must be recorded

MA 518: Database Management Systems 5


Example 1(b)
• A university database contains information about professors (identified by social
security number, or SSN) and courses (identified by courseid). Professors teach
courses; each of the following situations concerns the Teaches relationship set.
For each situation, draw an ER diagram that describes it (assuming no further
constraints hold).
• Professors can teach the same course in several semesters, and only the most
recent such offering needs to be recorded (Assume this condition applies in
all subsequent questions)

MA 518: Database Management Systems 6


Example 1(c)
• A university database contains information about professors (identified by social
security number, or SSN) and courses (identified by courseid). Professors teach
courses; each of the following situations concerns the Teaches relationship set.
For each situation, draw an ER diagram that describes it (assuming no further
constraints hold).
• Every professor must teach some course

MA 518: Database Management Systems 7


Example 1(d)
• A university database contains information about professors (identified by social
security number, or SSN) and courses (identified by courseid). Professors teach
courses; each of the following situations concerns the Teaches relationship set.
For each situation, draw an ER diagram that describes it (assuming no further
constraints hold).
• Every professor teaches exactly one course (no more, no less)

MA 518: Database Management Systems 8


Example 1(e)
• A university database contains information about professors (identified by social
security number, or SSN) and courses (identified by courseid). Professors teach
courses; each of the following situations concerns the Teaches relationship set.
For each situation, draw an ER diagram that describes it (assuming no further
constraints hold).
• Every professor teaches exactly one course (no more, no less), and every
course must be taught by some professor

MA 518: Database Management Systems 9


Example 1(f)
• Now suppose that certain courses can be taught by a team of
professors jointly, but it is possible that no one professor in a team
can teach the course. Model this situation, introducing additional
entity sets and relationship sets if necessary

MA 518: Database Management Systems 10


Whats wrong with these examples?
1. Product Purchase Person

Country President Person


2.
3. date
Product

Purchase Store

personAddr
personName
MA 518: Database Management Systems 11
Example 2
• A company database needs to store information about employees (identified
by ssn, with salary and phone as attributes), departments (identified by dno,
with dname and budget as attributes), and children of employees (with name
and age as attributes).
• Employees work in departments;
• each department is managed by an employee;
• a child must be identified uniquely by name when the parent (who is an employee;
assume that only one parent works for the company) is known.
• We are not interested in information about a child once the parent leaves the
company.
• Draw an ER diagram that captures this information (only major attributes
shown).
MA 518: Database Management Systems 12
DNO Dname
Works
SSN Salary in
(0,N) (0,N)
Phone Departments
Employees
(1,1)
(0,N)
(0,N)
Manages
budget
dependent

(1,1)

Children
cname

MA 518: Database Management Systems 13


Thank You

MA 518: Database Management Systems 14

You might also like