Data Modeling and Entity- Relationship Model II. IST2102 I want a database to maintain departments...
-
Upload
julius-king -
Category
Documents
-
view
215 -
download
0
Transcript of Data Modeling and Entity- Relationship Model II. IST2102 I want a database to maintain departments...
Data Modeling and Entity-Relationship Model II
IST210 2
I want a database to maintain departments in my company. Store
information about my employees, their projects and assignments. I want ….
$$$
User requirement
A database
YOUR JOB!
Data Modeling (Ch.4)
Database Design (Ch.5)
IST210 3
Overview of Chapter 4: Data Modeling
• Input: User requirement; Output: E-R Diagram• Use Entity-Relationship Diagram (E-R Diagram) to capture all user
requirements
IST210 4
Review of Previous Class: Draw an Entity
Entity Name
Attributes
Identifier
IST210 5
Review of Previous Class: Maximum Cardinality
• Relationships are named and classified by their cardinality, which is a word that means count
• maximum cardinality is the maximum number of entity instances that may participate in a relationship instance — one, many or other some fixed number– BASKETBALL-TEAM and PLAYER could be 1:5
IST210 6
Review of Previous Class: Crow’s Foot Notation
USER VIDEO
USER CHANNEL
EMPLOYEE LOCKER
One Many (crow’s foot)
Attention: do not misplace one and many notations
An employee has (at most) one locker; a locker can belong to (at most) one employee
A user can upload many videos; a video can be uploaded by (at most) one user
A user can subscribe to many channels; a channel can be subscribed by many users
upload
subscribe
IST210 7
How to Determine Maximum Cardinality?
USER VIDEO
USER CHANNEL
EMPLOYEE LOCKER
Attention: do not misplace one and many notations
An employee has (at most) one locker; a locker can belong to (at most) one employee
A user can upload many videos; a video can be uploaded by (at most) one user
A user can subscribe to many channels; a channel can be subscribed by many users
upload
subscribe
• User requirements• Common Sense
Review Exercise
• Use crow’s foot notation to draw maximum cardinality on the following relationships:
SALESPERSON ORDER
PRODUCT ORDER
EMPLOYEE DEPARTMENT(is manager of)
IST210 9
This Class
• Entity-Relationship Model– Entity, attribute, identifier, relationship– Maximum Cardinality: 1:1, 1:N, N:M– Minimum Cardinality: Optional, Mandatory
• Case Studies
IST210 10
Minimum Cardinality
• Minimum cardinality is the minimum number of entity instances that must participate in a relationship instance– typically assumes a value of zero (optional) or one
(mandatory)
Mandatory Optional
Crow’s foot notation
IST210 11
Minimum Cardinality
EMPLOYEE LOCKERAn employee may have a locker; a locker must belong to an employee
Mandatory Optional
Maximum cardinality notation is closer to entity
Minimum cardinality notation is closer to the middle
IST210 12
Minimum Cardinality: Exercise
USER VIDEO
Mandatory Optional
What does the Minimum cardinality mean?(A) A user must upload a video; a video may belong to a user(B) A user may upload a video; a video must belong to a user(C) A user may upload a video; a video may belong to a user(D) A user must upload a video; a video must belong to a user
IST210 13
Minimum Cardinality: Exercise
Which design is most suitable?• User requirements• Common sense
(A)
(B)
(C)
(D)
USER CHANNEL
subscribe
USER CHANNEL
USER CHANNEL
USER CHANNEL
IST210 14
In-Class Exercise: Minimum Cardinality
In-Class Exercise A-3• Add Minimum Cardinality symbols on the line of the
relationship
In-Class Exercise B-3• Add Minimum Cardinality symbols on the line of the
relationship
IST210 15
Multiple Relationships between Entities
StudentID ClubIDName
STUDENT CLUB
ClubName
Description
president
member
• Sometimes, there could multiple relationships with different semantic meanings between two entities. • A club will have exactly one student as the president.
Students can also become members of the club.
IST210 16
Multiple Relationships between Entities
UserID ProductIDName
USER PRODUCT
Name
Description
Sell
Buy
A product must be sold by exactly one user. A product may or may not have a buyer yet.
IST210 17
Summary
E-R Diagram: Entity-Relationship Diagram(1) entity; (2) identifier; (3) attributes; (4) relationship
UserID Video IDName
Address
USER VIDEO
Title
Description
Length
A complete E-R Diagram represented using Crow’s Foot notation:
USER –> VIDEO: A user may upload zero to many videosVIDEO–> USER: A video must belong to exactly one user