Upload
warren-barnett
View
213
Download
0
Tags:
Embed Size (px)
Citation preview
1
2
Data Modeling
3
Data Modeling Process of creating a logical
representation of the structure of the database
The most important task in database development
E-R Model Semantic Object Model Relational Model
Page 47
4
Entity Relationship Data Model
5
Entity-Relationship Data Model Explicitly represents entities and
their relationships Implementation independent For use at the conceptual and
external levels Peter Pin-San Chen,
The entity-relationship model---toward a unified view of data. ACM Transactions on Database Systems, Vol.1, No. 1, March 1976 - portal.acm.org
6
A picture with Peter Chen, the founder of E-R model
7
Entity-Relationship Data Model
Entity A thing, event, or person in the organization's
environment about which someone wants to collect data
Attribute Characteristic or property of an entity
Relationship Association between entities
Composite entity (Associative entity) Represents both an entity and relationship Has its own properties
8
Components of E-R Model
Entity
Relationship
Composite entity
Attribute
9
An E-R Model for Student Registration System
Entities
Course Instructor
Student
Course Enrollment
10
An E-R Model for Student Registration System
Course Instructor
Student
Advises
Teaches
NM
M
11
M
Relationships
Many-to-many
One-to-many
11
An E-R Model for Student Registration System
CompositeEntity
Course Instructor
Student
Advises
TeachesM
M
11
M
M
1
1Class Enrollment
12
An E-R Model for Student Registration System
CourseNumber
Description Instructor IDName
RankRoom
CourseNumber Grade
StudentNumber
StudentNumber
Major
StudentName
AttributesCourse Instructor
Student
Advises
TeachesM
M
11
M
M
1
1Class Enrollment
Entities“something that users track”
Page 49Figure 3-1 © 2000 Prentice Hall
14
Attributes (properties)
“describe the entity’s characteristics”Entity:EmployeeAttributes:EmployeeName, Extension,
DateOfHire, JobSkillCode Attribute type
Key attribute or identifier (i.e. employee number) Single value attribute (i.e. spouse) Multivalued attribute (i.e. children) Derived attribute (i.e. tax payment)
Page 50
15
More about Entities Existence Dependency
The existence of one entity depends on the existence of one or more other entities
Fundamental entity vs. Attributive entity or Weak entity
A weak entity is one that is existence-dependent and has a primary key that is partially or totally derived from the parent entity in the relationship.
Entity Supertypes and Subtypes Exclusive (disjoint) and Inclusive (overlapping) Covering and non-covering
Subtype Entities“an entity that contains option sets
of attributes”
Page 56Figure 3-10b © 2000 Prentice Hall
17
Relationships A relationship is an association between
entities. A unary relationship exists when an
association is maintained within a single entity. (Recursive relationship)
A binary relationship exists when two entities are associated. (Most common)
A ternary relationship exists when three entities are associated. (e.g. real estate sales: buyer, seller, and property)
18
Classroom Assignment
Course
Time Slots
Classroom ClassroomAssignment
1
M
1
1M
M
Convert a ternary relationship to three binary relationships
Relationships“associations between entities”
Page 51Figure 3-3 © 2000 Prentice Hall
20
Connectivity and Cardinality The term connectivity is used to describe
the relationship classification (e.g., one-to-one, one-to-many, and many-to-many).
Cardinality expresses the specific number of entity occurrences associated with one occurrence of the related entity.
Relational Participation: Optional, Mandatory The actual number of associated entities is
usually a function of an organization’s policy.
21
Connectivity and Cardinality
Professor teaches Course
Connectivity
1 M
(0,3) (1,1)
Mandatory entityOptional entity
Cardinality
22
Building E-R Model Understand business rules and
assumptions Identify entities Identify relationships Identify attributes Check and improve E-R model Convert E-R model to relational
tables
Business rules A business rule is a statement that
defines or constrains some aspect of the business.
Business rules and policies govern creating, updating, and removing data in an information processing and storage system.
23
Example of business rules A student can take up to five courses
each term Each course will be taught by only one
teacher A customer must use valid credit card
to make online payment A flower order can deliver to anywhere
in North America but only one location
24
Business rules As a database analyst, you need to: Identify and understand those rules
that govern data Represent those rules so that they
can be unambiguously understood Implement those rules in database
technology
25
26
Sales Order Form
27
An E-R Model for Order Processing:
ProductNumber
Description
Customer Name
Address
Unit priceQuantity
OrderNumber Date
S NameS ID
Orders
Total
28
An E-R Model for Order Processing: Entities
ProductsCustomer
Orders
Salesman
29
An E-R Model for Order Processing: Relationships
ProductsCustomer
Orders
1
M
M
1
1
Salesman
M
OrderLine
Prepared Placed
M
1
30
An E-R Model for Order Processing: Attributes
ProductNumber
Description
Customer Name
AddressUnit price
ProductNumber
Quantity
OrderNumber
OrderNumber DateCustomer
Name
S Name S ID
S ID
ProductsCustomer
Orders
1
M
M
1
1
Salesman
M
OrderLine
Prepared Placed
M
1
31
Crow's Foot Notation of E-R Diagram with Attributes Shown
Cardinality Symbols of Relationships for ERD
33
Check and improve E-R model Convert a multivalued attribute
into an attribute entity or weak entity
Introduce composite entity to convert a m:n relation into two 1:m relations. Introduce a composite key
34
Check and improve E-R model
Each entity must have a key (simple or composite)
Make each attribute associate with only one entity unless it is a foreign key
Make each entity represent a simple object or concept
Divide complex entity into several related simple entities
35
Example:A Construction Company
A manager may manage many projects. Each project requires the services of many
employees. An employee may be assigned to several different
projects. Some employees are not assigned to a project and
perform duties not specifically related to a project. Some employees are part of a labor pool, to be shared by all project teams.
Each employee has a (single) primary job classification. This job classification determines the hourly billing rate.
Many employees can have the same job classification.
36
A E-R Model for A Construction Company
Project Employee
Job class
Assignment
37
A E-R Model for A Construction Company
Manager Worker
Subclass
Project Employee
Job class
Assignment
38
A E-R Model for A Construction Company
Project Employee
Job class
1
M
M
M 1
1
M
Assignment
Manages
Has
1
39
A E-R Model for A Construction Company
ProjectNumber
Project name
Job Code
Job Description
HourRate
Manager ID
ProjectNumber
Hours
EmployeeNumber
EmployeeNumber
EmployeeName
AssignmentNumber
Hire DateProject Employee
Job class
1
M
M
M 1
1
M
Assignment
Manages
Has
1
40
The Semantic Object Model
Semantic Object Model E. F. Codd, “Extending the Relational
Model to Capture More Meaning,” ACM Transactions on Database Systems, Dec. 1976, pp. 397-424.
Micheal Hammer and Dennis McLeod, “Database Description with SDM: A Semantic Database Model,” ACM Transactions on Database Systems, Setp. 1981, pp 351-386.
41
42
Semantic Objects
“a named collection of attributes that sufficiently describes a distinct entity”
Student Customer Employee
Page 74
43
Attributes“define the characteristics of semantic
objects”
Page 75Figure 4-2a © 2000 Prentice Hall
44
Attribute Cardinality“indicates the minimum or maximum number
of instances of the attribute that must exist in order for the object to be valid”
Page 76Figure 4-2b © 2000 Prentice Hall
45
Object Instances“the occurrence of a particular semantic
object”
Page 77Figure 4-3 © 2000 Prentice Hall
46
Object Identifier
“one or more object attributes that the users employ to identify object instances”
Example: CustomerID for Customer
Page 78
47
Domain
“a description of an attribute’s possible values”
Page 78
48
Semantic Object View“the portion of an object that is visible to
a particular application; view”
Page 79Figure 4-4 © 2000 Prentice Hall
49
Highline UniversityAdministration Database Objects:
College Department Professor Student
Page 80
50
Semantic Object Diagrams
Page 85Figure 4-13 (1) © 2000 Prentice Hall
51
Semantic Object Diagrams
Page 85Figure 4-13 (2) © 2000 Prentice Hall
52
Semantic Object Diagrams
Page 85Figure 4-13 (3) © 2000 Prentice Hall
53
Semantic Object Diagrams
Page 85Figure 4-13 (4) © 2000 Prentice Hall
54
Sales Order Form
55
Semantic vs. E-R Model
Page 105Figure 4-34 © 2000 Prentice Hall
56
Semantic vs. E-R Model
Page 105Figure 4-33 © 2000 Prentice Hall