Sie sind auf Seite 1von 21

Lecture 02

Lecture 02
Lecture 02
Lecture 02
..

Lecture 02
Lecture 02
Lecture 02
Lecture 02
Lecture 02
ERD Symbols

1 M
Entity

M 1
Attribute

1 1
Relationship

Lecture 02
Lecture 02
Example of drawing ER Diagram
Question: Make an ER Diagram for the company database with
the following description:
• The company is organized into departments. Each department has a
unique name and a unique number. A department may have one
locations.
• A department controls a number of projects, each of which has a unique
name, a unique number and a single location.
• We store each employee’s name, social security number, address and
salary. An employee is assigned to one department but may work on
several projects, which are not necessarily controlled by the same
departments.
• We want to keep track of the departments of each employee for
insurance purposes. We keep each dependent’s name, age and
relationship to the employee.

Lecture 02
Example of drawing ER Diagram
Answer:
Step 1: Identifies Entities of the given problem.

Entities:
1. DEPARTMENT (From 1st Point).
2. PROJECT (From 2nd Point).
3. EMPLOYEE (From 3rd Point).
4. DEPENDENT (From 4th Point).

Lecture 02
Example of drawing ER Diagram
Step 2: Identify the attributes of these entities.

Attributes:
1. DEPARTMENT: Name, Number, Location
2. PROJECT: Name, Number, Location
3. EMPLOYEE: SSN, Name, Address, Salary
4. DEPENDENT: Name, Age, Relationship

Lecture 02
Example of drawing ER Diagram
Step 3: Identify the Primary Keys of all entities identified
in Step 1.
Primay Keys:
1. DEPARTMENT: Name, Number, Location
(Unique Name and Unique Number)
2. PROJECT: Name, Number, Location
(Unique Name and Unique Number)
3. EMPLOYEE: SSN, Name, Address, Salary
(Unique Social Security Number)
4. DEPENDENT: Name, Age, Relationship
(No Unique Attribute for Dependent)

Lecture 02
Example of drawing ER Diagram
Step 4: Identify the Relationships between the entities.

Relationships :

Relationship Name Entities


1. Works_For EMPLOYEE & DEPARTMENT
2. Control DEPARTMENT & PROJECT
3. Works_On EMPLOYEE & PROJECT
4. Dependents_Of EMPLOYEE & DEPENDENT

Lecture 02
Example of drawing ER Diagram
Step 5: Identify the constraints on the entities.

Cardinality Constraints:

Relationship Name Cardinality Entities


1. Works_For M:1 EMPLOYEE & DEPARTMENT
2. Control 1:M DEPARTMENT & PROJECT
3. Works_On M:M EMPLOYEE & PROJECT
4. Dependents_Of 1:M EMPLOYEE & DEPENDENT

Lecture 02
Example of drawing ER Diagram
Step 6: Draw ER Diagram.

Lecture 02
Distributed Examples of ERD

Lecture 02
Question1:
Construct an E-R diagram for a hospital with a set of patients and
a set of medical doctors. Associate with each patient a log of the
various tests and examinations conducted.

Question2:
Construct an E-R diagram for a school academic part only.

Question3:
Construct an E-R diagram for a payroll system.

Question4:
Construct an E-R diagram for a Library System with borrowing.

Lecture 02
END OF SECOND LECTURE
See you in the third lecture
With My Best Wishes
Hamdy Esckander

Lecture 02

Das könnte Ihnen auch gefallen