Upload
amr
View
220
Download
0
Embed Size (px)
DESCRIPTION
database
Citation preview
1
Georgia State University--CIS 850/330 Entity Relationship Modeling
Entity-Relationship Diagrams
Georgia State University--CIS 850/330 Entity Relationship Modeling
Entity-Relationship Diagrams
Contents:
Data ModelingUser ViewsEntities/ Entity SetsAttributesEntity-Relationship Diagrams (ERDs)Finding Entities and RelationshipsEnglish Grammar RulesRegistration Example
Student RegistrationCourse EnrollmentGrade Report
Relationship AttributesExtended ERD
Note: The Entity-Relationship Diagrams presented in thisclass are based on James Martin’s Information Enginneringapproach.
2
Georgia State University--CIS 850/330 Entity Relationship Modeling
Design ApproachSteps:
1. Model User View
2. Normalize these relations
3. Represent all keys
4. Merge the result of the previous steps into the cumulative design.
User View
Collection of Tables
Collection of BCNF Tables
Collection of BCNF Tables with Keys Represented
New Cumulative Design
Old Cumulative Design
Georgia State University--CIS 850/330 Entity Relationship Modeling
Model User View
Advantages of Data Modeling:
+ Data Analysis vs. Process Analysis
+ Graphical Models vs. Prose
+ “Data is more stable than processes.”
3
Georgia State University--CIS 850/330 Entity Relationship Modeling
User Views
A user view is the view of the data that is necessaryto support the operations of a particular user.
Example: Wells Junior College
User View #1 -- Registration
User View #2 -- Class Enrollment
User View #2 -- Grade Reporting
Georgia State University--CIS 850/330 Entity Relationship Modeling
Entities/ Entity Set
An entity is a person, place, object, event, or concept about which the organization wishes to record data.
Rules: An entity . . .1. Must be within the scope of the system2. Must have at least one non-key attribute
An entity type is a collection of entities witha similar data structure.
4
Georgia State University--CIS 850/330 Entity Relationship Modeling
Entity Type -- Examples
Customer
Product
Supplier
Georgia State University--CIS 850/330 Entity Relationship Modeling
Entity Instance (Entity)
Sally Smith
PS/2,model 60,ID#Qty-on-Hand
Panasonic, model 82sm
Allen Baker
5
Georgia State University--CIS 850/330 Entity Relationship Modeling
Attributes
An attribute is a property of an entity that we choose to record.
Attributes of Customer entity:
Social security numberNameAddressDate of birth
Georgia State University--CIS 850/330 Entity Relationship Modeling
Entity-Relationship Diagrams
An Entity-Relationship Diagram (ERD) is a graphicalportrayal of entities and their relationships.
Entity types are shown in rectangles andrelationship types are shown as the lines that connect related entity types.
Employee ProjectWorks for
6
Georgia State University--CIS 850/330 Entity Relationship Modeling
Entity-Relationship Diagrams (ERDs)
Entity types Class
Student ClassEnrolls in
is taken by
Relationships are named; sometimes in both directions.
Student
Georgia State University--CIS 850/330 Entity Relationship Modeling
Many represenation forms: Chen (min/max), Booch, Codd/Yordon, Crows feet...
Default and prefered method in SA is Crows feet
Difference between Min/Max and Crows feet:– how cardinality and participation is expressed.
– the existence of the Assocation Diamond
Relationship: Cardinalities and Participation
7
Georgia State University--CIS 850/330 Entity Relationship Modeling
Chen’s (Min/Max)Notation:Cardinalities and Participation
Read in terms of the entity instance you are leaving. i.e. E1
E1 E2R(min, max) (min, max)
Participation 0 -- Partial 1 -- Total (mandatory)
Cardinality 1 -- one M -- more than one
Relationship diamond
Georgia State University--CIS 850/330 Entity Relationship Modeling
Chen’s (Min/Max)Notation: anexample
Read: A Customer may participate in from zero to many relationships
Customer OrderPlaces(0, M) (1, 1)
Participation 0 -- Partial 1 -- Total (mandatory)
Cardinality 1 -- one M -- more than one
Relationship
8
Georgia State University--CIS 850/330 Entity Relationship Modeling
Chen’s (Min/Max)Notation: anexample
Instructor OfficeAssign(1,1) (0,1)
DepartmentWork_for
(1,1)
(0,m)
Teach
(0,m)
(0,m)
Course
Date
Language
Emp#
NameFName
MInit LName
Time
Location
Date
Georgia State University--CIS 850/330 Entity Relationship Modeling
Crows Foot Notation
Read in terms of the relationship with which an entity instance is participating
Participation and Cardinality are shown by the crows feet.
Customer OrderPlaces
Read: A customer places (or may place) zero to
many orders; An order is placed by one and
only one Customer
9
Georgia State University--CIS 850/330 Entity Relationship Modeling
A is related to one and only one B
A is related to zero or one B
A is related to one or more B
A is related to zero, one or more B
A is related to more than one B
Relationship Cardinalities
A
A
A B
B
BA
A
B
B
Georgia State University--CIS 850/330 Entity Relationship Modeling
Cardinality Examples
Employee Dependent Claims
is-claimed-by
Instructor Class Teaches
is-taught-by
Customer OrderPlacesIs-Placed-by
10
Georgia State University--CIS 850/330 Entity Relationship Modeling
Finding Entities and Relationships
1. Identify the system informationa. User interviewsb. Paper and screen documentsc. Previous system documentation
2. Identify entitiesa. Heuristicsb. Analysis of English grammar -->
Entity-Relationship Diagramsc. Normalization process
Georgia State University--CIS 850/330 Entity Relationship Modeling
Entity Identification: English Grammar - Rule #1
English ERD
Proper Noun Entity (“Name” of an Entity)
Common Noun Entity or Entity-Type
Transitive Verb M-ary Relation (M>1)
Intransitive Verb Unary Relationship or Attribute Value
Adjective Attribute of an Entity
Adverb Attribute of a Relationship
11
Georgia State University--CIS 850/330 Entity Relationship Modeling
Convert any sentence in the following form:“There are . . . X in Y”
into“Y has . . . X”
Entity Identification: English Grammar - Rule #1
Example: X Y“There are more than 200 employees in every department.”
Y X “Every department has more than 200 employees.”
Department Employee
Georgia State University--CIS 850/330 Entity Relationship Modeling
English Grammar - 3
If the English sentence says, “The X of Y is Z”
Rule #3: Y is an Entity
Rule #4: X is either an Attribute or an Entity, depending on what type of “Z” it is.
Rule #5a: If “Z” is a proper noun, then X is aRelationship between Y and Z
Rule #5b: Otherwise, X is an Attribute of Y
12
Georgia State University--CIS 850/330 Entity Relationship Modeling
Grammar - 3 (Examples)
The birthdate of the student is 10/22/71.(x) (y) (z)
Attribute Entity not a proper noun
Student Birthdate * “10/22/71”
The advisor of John Smith is Dr. Greene. (x) (y) (z)Relationship Proper noun
Student * Advisor *
Georgia State University--CIS 850/330 Entity Relationship Modeling
ERD for Student Registration
Student
Advisor
Course
Instructor
Advises/is advised by
Enrolls in
is taken by
Is taught by/teaches
* Note: Attributes should be specified for each entity-type
13
Georgia State University--CIS 850/330 Entity Relationship Modeling
ERD for Course Enrollment
Student Course
Instructor
Enrolls in
is taken by
Is taught by/teaches
* Note: Attributes should be specified for each entity-type
Georgia State University--CIS 850/330 Entity Relationship Modeling
ERD for Grade Report
Student
Advisor
Course
Instructor
Advises/is advised by
Enrolls in
is taken by
Is taught by/teaches Grade
* Note: Attributes should be specified for each entity-type
Earns
Applies to
14
Georgia State University--CIS 850/330 Entity Relationship Modeling
Relationship Attributes
If a Relationship has Attributes,
For example:
Works for
• An Employee is assigned to a project for a certain % of time.• An Employee has a particular role for each project he/she
works on (e.g., programmer, analyst, project manager, etc.)
Employee Project
Georgia State University--CIS 850/330 Entity Relationship Modeling
Relationship-Entity
Employee Project
Then the Relationship becomes a Relationship-Entity:
Project-Assignment
15
Georgia State University--CIS 850/330 Entity Relationship Modeling
Extended Model
* Note: Attributes should be specified for each entity-type
Student Course
Advises/is advised by
Enrolls in
is taken by
Is taught by/teaches
Grade
Department
Earns Applies to
Employs
Works for Faculty
Advisor
Instructor
Georgia State University--CIS 850/330 Entity Relationship Modeling
Review
Definitions:
User ViewEntity, Entity-TypeRelationshipCardinality
Using English Grammar to identifyEntities and Relationships
Entity-Relationship Diagrams