Designing ERDs

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

Diagrams 1

ERD
Data Focused view of an IS
Defining an ERD 2

 An Entity Relationship Diagram (ERD) is a visual representation of different entities within a


system and how they relate to each other
 ERDs help to identify different system elements and their relationships with each other
 They are widely used to design relational databases.
 The entities in the ERD become tables, attributes and are converted into the database schema.
 Their ability to visualize database tables and their relationships enable their use in database
troubleshooting.
Symbols Used 3

Entity

Relationship

Attribute
ER-Diagrams: General Information 4

 ER-diagrams are a formalism to model real-world scenarios


 ERDs focus on the data while DFDs focus on processes
 There are many versions of ER-diagrams that differ both in their appearance and in
their meaning
 ER-diagrams have a formal semantics (meaning) that must be thoroughly
understood, in order to create correct diagrams
Entities 5
Entity:
 An object in the world that can be distinguished from other objects
 Can either be abstract or physical
 Examples of abstract entities: Course, Lesson
 Examples of physical entities: Student, Lecturer
6
Types of Entities
 Strong Entity
 Can exist on its own Employee
 Commonly modelled type of entity

 Weak Entity Dependent

 Exists in relation of a strong entity


 Borrows identity from strong entity
Attributes
7
 Attributes :used to describe entities
 All entities in the set have the same attributes
 A minimal set of attributes that uniquely identify an entity is called a primary key
 Primary keys are identified by underlining
Studentnumber
 An attribute contains a single piece of information (and not a list of data)
Types of attributes
 Simple attributes - single valued 8
Stud_Id

 Multi-valued
 Has several vales Phone_num
 Person can have several numbers Street

 Composite attributes Address


 Can be broken down to components City

 Derived/calculated
Tax
 Computed from other attributes
9
Example with attributes

street city

name address
id DOB

Student

Entity with attributes, address is a composite attribute


Relationships,
10
 Relationship : Association among two or more entities
 Relationships may have attributes
 Examples of Relationships: has, does, teaches,
 A relationship can be described in 2 ways according to which entity we refer to
first.
 Lecturer teaches a course or a course is taught by a lecturer
 Can be 1:1; 1:M; M:N
Example ERD 11

title
birthday

id
M N
Actor acts-in Film year

name

address type

*The ERD here shows that several actors act in several films
*This means, one actor is associated with many films, and one film is associated with a
number of actors.
Types of Relationships 12

 Refers to the number of entity types participating in a relationship


i. Unary relationship
ii. Binary relationship
iii. Ternary relationship
iv. -----
Types of Relationships 13

i. Unary – One entity participates in the relationship

phone
number
manages

id

Employee Manages
worker
name

address
Binary

14
Relates two entities
 Can be 1: 1; 1 : M; M:N

id 1 M
Director Directs Film title

name

Suggest meaningful examples of 1:1 and M:N relationships


Ternary Relationship
15

Item_Id

Item Supp_Id
Cust_Id

Customer orders Supplier

• Ternary relationship relates three entities


• A customer orders items from a supplier
• We have left out other attributes to avoid clutter
Steps in Producing an ERD 16

1. Identify all objects about which data is to be stored


2. For each object identify all attributes to be stored
3. Construct a cross reference matrix of all pairs of objects &
identify possible relationships.
4. Draw a basic ERD showing all the possible relationships, without
the degrees
5. Indicate the degrees of the relationships on the diagram, 1:1;,
1:M; & M;N
Example: Step1 Entity Identification 17

Suppose in a university the following entities exist:


 Student
 Course
 Sponsor
 Department
Step 2: Identifying Attributes 18

Student: Stud_Id, Name, Address, Gender, Dob, Guardian


Course: Course code, Course description, department, course leader
Sponsor: Sponsor code, Address, Phone
Department: Dept Name, Location, Number, Chairperson
Step3: Cross Reference matrix 19

Student Course Sponsor Dept

Student Y Y Y

Course N Y

Sponsor N

Dept
Produce ERD 20

 Step 4 and 5 can be combined, that is produce the ERD from the
matrix.
 Resolve M:N relationships
Resulting ERD (Step 4 & Step 5) 21
Stud_Id
Stud_Id

M N
Student
takes Course

M
M
M
has enr
oll run by
s- in
Dept_Name
Stud_Id N 1

Sponsor 1
Dept.
Data analysis 22

 ERDs provide a basis for normalization


 The ERD is systematically translated to tables
 Tables are then normalized for data consistency (in database design)
23
Problem
Activities in a local clinic are described as follows:
There is one doctor who attends to all patients. Only patients needing specialist
care are attended to by the doctor. All other patients are attended to by the nurses in
the clinic. All patients arriving at the clinic report to the clinic clerk. There is only
one clerk at the clinic. Once patients get their clinic cards from the clerk, they
report to the consulting nurse, who prescribes the medication for minor illnesses.
Patients with minor illnesses are treated by the nurse stationed at the treatment
room. Patients requiring doctor’s care are booked for the doctor who comes twice a
week.
Task: Produce an ERD for the description of the clinic environment.

You might also like