ERD_(Chapt_2)
-
Upload
noor-suriani-nazruddin -
Category
Documents
-
view
214 -
download
0
Transcript of ERD_(Chapt_2)
-
7/31/2019 ERD_(Chapt_2)
1/33
1
Objectives:
To illustrate how relationships between entities are defined and
refined.
To know how relationships are incorporated into the database
design process.
To describe how ERD components affect database design and
implementation.
-
7/31/2019 ERD_(Chapt_2)
2/33
2
Entity Relationship Diagram (ERD)
A detailed, logical representation of the entities,associations and data elements for anorganization or business
Notation uses three main constructs :
Entities
Relationships Attributes
Chen Model or
Crows Foot
Model
DEFINITION
-
7/31/2019 ERD_(Chapt_2)
3/33
3
DIFFERENCES OF MODEL
Crows Foot Chen
Entity
Attribute
Relationship
Department
Staff No.
employs
Staff No
Department
Department2
2
employs
-
7/31/2019 ERD_(Chapt_2)
4/33
Person, place, object, event
or concept about which data
is to be maintained
named property or
characteristic of an
entity
Association
between the
instances of one or
more entity types
Represents a set or collection of
objects in the real world that
share the same properties
Chen Notation
EntityName Verb Phrase AttributeName
-
7/31/2019 ERD_(Chapt_2)
5/33
5
ENTITY
An entity is a thing of interest to a system about whichinformation is kept
For example in a Hospital Administration System, some likelyentities would include: Patient, Doctor, Operation, Ward
Each of these things are of interest to the system and wouldhave data stored about them
5
-
7/31/2019 ERD_(Chapt_2)
6/33
6
ENTITIES EXAMPLES
Examples of entities: Person: EMPLOYEE, STUDENT, PATIENT
Place: STORE, WAREHOUSE
Object: MACHINE, PRODUCT, CAR
Event: SALE,REGISTRATION, RENEWAL
Concept: ACCOUNT, COURSE
Guidelines for naming and defining entity types: An entity type name is a singular noun
An entity type should be descriptive and specific An entity name should be concise
Event entity types should be named for the result of the event,not the activity or process of the event.
-
7/31/2019 ERD_(Chapt_2)
7/33
-
7/31/2019 ERD_(Chapt_2)
8/338
ATTRIBUTE
An attribute is an item of data held about an entity
In computer systems an attribute is a field of information
Example : Sales System
Entity : Customer
Attributes : Customer Name, Customer Address, Customer Phone
Number
-
7/31/2019 ERD_(Chapt_2)
9/339
Entity : STUDENT
Attributes: Student_ID, Student_Name, Home_Address,Phone_Number, Major
Guidelines for naming attributes:
An attribute name is a noun.
An attribute name should be unique
To make an attribute name unique and clear, each attribute
name should follow a standard format
Similar attributes of different entity types should use similarbut distinguishing names.
-
7/31/2019 ERD_(Chapt_2)
10/3310
KEYS
A key attribute uniquely identifies a specific occurrence of an entity
This may also be referred to as a primary key
Examples of primary keys include:
ISBN
Student Number
Staff ID
10
-
7/31/2019 ERD_(Chapt_2)
11/3311
EXAMPLE
In a Sales System, customer name and address are
attributesof the entitycustomer.
The primary keyis likely to be Customer Code or
Customer ID as the unique identifier for each customer in the
system.
11
-
7/31/2019 ERD_(Chapt_2)
12/33
-
7/31/2019 ERD_(Chapt_2)
13/3313
EXAMPLE : BABYSITTERSERVICE
The AITP Service Club wants to run a babysitting service.
Customers call to request a sitter and the Club Coordinator
assigns an employee to sit for the customer from a list of
employees available for the particular day requested.
13
-
7/31/2019 ERD_(Chapt_2)
14/3314
BABYSITTING SYSTEM
Data is used to:
Assign employee to job
Determine availability
Data to be captured in database:
Employee data
Job data
Customer data
14
-
7/31/2019 ERD_(Chapt_2)
15/3315
BABYSITTING SYSTEM
Employee
Attributes: EmpID, Name, Address,
Phone Number, Available Hours,JobNo Job
Attributes: JobNo, JobDate, JobTime,EmpID
Customer
Attributes: CusNo, Name, Address,Phone Number, JobNo
15
-
7/31/2019 ERD_(Chapt_2)
16/3316
ERD - Babysitter Service
-
7/31/2019 ERD_(Chapt_2)
17/3317
17
ERD - Babysitter Service
EMPLOYEE
JOB
CUSTOMER
Related toassigned to
1
MN
M
-
7/31/2019 ERD_(Chapt_2)
18/3318
TO BE CONTINUED
-
7/31/2019 ERD_(Chapt_2)
19/3319
FOREIGN KEYDefinition
A foreign key is a relationship or link between two tableswhich ensures
that the data stored in a database is consistent.
Example:
In the example, there is a link between the Company and Contact tables.
The Company table is the parent table in the link. The Contact table is the
child: the Company_ID field in the Contact table indicates which Company
a Contact belongs to.
-
7/31/2019 ERD_(Chapt_2)
20/33
-
7/31/2019 ERD_(Chapt_2)
21/33
21
RELATIONSHIPS
DEFINITION:
Associations between instances of one or more entity types
that is of interest
Author Book
Relationship name:write
An author writes one or more books
A book can be written by one or more authors.
write
-
7/31/2019 ERD_(Chapt_2)
22/33
22
DEGREE O F RELA T IO NSHIPS
Degree: number of entity types that participate in a relationship
Three cases
Unary: between two instances of one entity type
Binary: between the instances of two entity types
Ternary: among the instances of three entity types
-
7/31/2019 ERD_(Chapt_2)
23/33
23
C ARD INAL ITY AND
CONNECTIVITY
Relationships can be classified as either one to one ( 1:1 )
one to many (1:M)
many tomany (M:N)
Cardinality: minimum and maximum number
of instances of Entity B that can (or must be)
associated with each instance of Entity A.
Connectivity
-
7/31/2019 ERD_(Chapt_2)
24/33
24
2 . 4 C A R D IN A L ITY A N D C O N N E C TIVITY
A professor teaches class OR
A class is taught by professor
How Many??
PROFESSOR CLASSteaches
-
7/31/2019 ERD_(Chapt_2)
25/33
25
CARDINALITY AND CONNECTIVITY
1 MPROFESSOR CLASSteaches
Connectivity
(1,1)(1,4)
Cardinality
-
7/31/2019 ERD_(Chapt_2)
26/33
26
CONNECTIVITY
Chen Model
1 to represent one
M to represent many
1
M
-
7/31/2019 ERD_(Chapt_2)
27/33
27
BINARY RELATIONSHIPS
1:M relationship
Relational modeling ideal
Should be the norm in any relational database design
The 1: M relationship between PAINTER and PAINTING
-
7/31/2019 ERD_(Chapt_2)
28/33
-
7/31/2019 ERD_(Chapt_2)
29/33
29
BINARY RELATIONSHIPS
1:1 relationship
Should be rare in any relational database design
A single entity instance in one entity class is related
to a single entity instance in another entity class
Could indicate that two entities actually belong in
the same table
-
7/31/2019 ERD_(Chapt_2)
30/33
-
7/31/2019 ERD_(Chapt_2)
31/33
31
BINARY RELATIONSHIPS
M:N relationships
Can be implemented by breaking it up to produce a set of
1:M relationships
-
7/31/2019 ERD_(Chapt_2)
32/33
The M:N Relationship Between STUDENT and CLASS
This CANNOT be implemented as shown next..
Bowser
Smithson
Accounting 1 (ACCT-211)
Intro to Microcomputing (CIS-220)
Intro to Statistics (QM-261)
-
7/31/2019 ERD_(Chapt_2)
33/33
~The END~
Q & A