Академический Документы
Профессиональный Документы
Культура Документы
Lesson Outcomes
At the end of the lesson, students should be able to :
Conceptually depict a database structure in an ER Diagram
(using Chen Notation)
Identify and describe the main characteristics of ERDs
components such as
Entity
Attributes
Identifier attributes (Keys) Primary/Composite/Foreign
Composite and simple attributes
Single-valued and Multivalued attributes
Relationships
Connectivity & cardinality
Degree of relationship
2
name
custID
qtyBought
price
prodID
PRODUCT
purchasedBy
name
CUSTOMER
m
contactNo
suppliedBy
suppID
1
SUPPLIER
name
address
contactNo
Intro to Modeling
In the programming env., a problem that needs to be solved
must be critically analyze first before a solution can be designed.
In programming, the analysis will identify (1) the inputs (2) the
outputs (3) the process
After that an approach to solve the problem will be selected, e.g.,
procedural/structured, object-oriented, logical etc.
Then, if for example, structured approach is selected, then the
solution will be designed using certain model, e.g., flowchart,
pseudocode, etc.
4
Variation in ER Model
One-to-One
One-to-Many
CUSTOMER
ACCOUNT
STUDENT
COURSE
CUSTOMER
ACCOUNT
STUDENT
COURSE
ACCOUNT
STUDENT
COURSE
ACCOUNT
STUDENT
EMPLOYEE
TEMP_EMP
EMPLOYEE
TEMP_EMP
EMPLOYEE
TEMP_EMP
CUSTOMER
TEMP_EMP
CUSTOMER
3
4
5
EMPLOYEE
EMPLOYEE
TEMP_EMP
Many-to-Many
CUSTOMER
ACCOUNT
(1) Ross, (2) Bachmann, (3) Martin (crow foot), (4) Chen, (5) Rumbaugh.
STUDENT
COURSE
COURSE
Chen Notation
Association
between the
instances of one or
more entity types
EntityName
Verb Phrase
AttributeName
named property or
characteristic of an
entity
Entities
Entities contd
Examples of entities:
Attributes
Characteristics of entities
In Chen model, attributes are represented by ovals
and are connected to entity rectangle with a line
Each oval contains the name of attribute it
represents
In Crows Foot model, attributes are written in
attribute box below entity rectangle (oval also
acceptable)
13
Attributes contd
Example of entity types and associated attributes:
STUDENT: Student_ID, Student_Name, Home_Address,
Phone_Number, Major
15
Composite
attribute
Simple
attribute
fname
age
name
STUDENT
lname
16
Ex. CAR_MODEL_NO
Multivalued attributes
can have many values
Ex. A car color may be
subdivided into many
colors (colors for the
roof, body and trim)
Chen Model, the
multivalued attributes are
shown by double line
connecting the attribute
to the entity.
17
18
ERD :: 19 / 1 / 07
18
20
ERD :: 19 / 1 / 07
20
21
ERD :: 19 / 1 / 07
21
Identifier vs non-identifierAttributes
Non-identifier
Attribute which is not unique among instances of an entity
Candidate key
Attribute (or combination of attributes) that uniquely identifies each
instance of an entity type
Some entities may have more than one candidate key
Ex: A candidate key for EMPLOYEE is Employee_ID, a second is the
combination of Employee_Name and Address.
If there is more than one candidate key, need to make a choice.
Identifier/primary key
A candidate key that has been selected as the unique identifying
characteristic for an entity type
Example
Chen Notation
Name
Gender
IC
StaffID
Staff
Name
Gender
IC
Instance of Lecturer.
Name
IdNum
DeptID
Ali
105
LG
ali@a.com
Mary
106
IT
mary@a.com
John
107
ENG
john@a.com
Lim
108
IT
lim@a.com
Derived Attributes
Attribute whose value may be calculated (derived) from
other attributes.
Ex. EMP_AGE can be derived by computing the difference between
the current date and the EMP_DOB
25
Relationships
Associations between instances of one or more entity types that is of interest
Given a name that describes its function.
relationship name is an active or a passive verb.
Relationship name:
writes
Author
Book
Degree of Relationships
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
Connectivity
Professor
Professor
teaches
teaches
Class
Class
How Many??
1
Professor
M
teaches
(1,4)
Class
(1,1)
Cardinality
Connectivity
teaches
Professor
(1,1)
Class
(1,4)
Cardinality
Connectivity
Chen Model
1 to represent one.
M to represent many
1
M
Crows Foot
One
many
One or many
Mandatory one , means (1,1)
Optional? well see after this
Binary Relationships
1:M relationship
Binary Relationships
1:1 relationship
The Implemented
1:1 Relationship
Between
PROFESSOR
and
DEPARTMENT
Binary Relationships
M:N relationships
This will be used to link the tables that were originally related
in a M:N relationship
Accounting 1 (ACCT-211)
Intro to Microcomputing (CIS-220)
Intro to Statistics (QM-261)
+ CLASS_CODE
CLASS_CODE
+ STU_NUM
Optional
handles
Lecturer
(1,1)
Lecturer
1
(0,N)
Class
(0,N)
M
handles
Class
(1,1)
Weak Entities
Weak entity meets two conditions
Existence-dependent
Cannot exist without entity with which it has a
relationship
43
ERD :: 19 / 1 / 07
43
Recursive Relationships
Relationshiptypewheresameentitytype
participatesmorethanonceindifferentroles
Relationship can exist between
occurrences of the same entity set
Naturally found within unary relationship
44
Recursive Relationships
45
46
ERD :: 19 / 1 / 07
46
47
ERD :: 19 / 1 / 07
47
Lesson Summary
ERD is a diagram that can be used to represent structure
of a database.
There are 3 main components of a database structure (1)
entity (2) attribute (3) relationship
All entities must be directly connected to at least one
other entity in the ERD.