56
1

1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

Embed Size (px)

Citation preview

Page 1: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

1

Page 2: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

2

Data Modeling

Page 3: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 4: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

4

Entity Relationship Data Model

Page 5: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 6: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

6

A picture with Peter Chen, the founder of E-R model

Page 7: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 8: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

8

Components of E-R Model

Entity

Relationship

Composite entity

Attribute

Page 9: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

9

An E-R Model for Student Registration System

Entities

Course Instructor

Student

Page 10: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 11: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

11

An E-R Model for Student Registration System

CompositeEntity

Course Instructor

Student

Advises

TeachesM

M

11

M

M

1

1Class Enrollment

Page 12: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 13: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

Entities“something that users track”

Page 49Figure 3-1 © 2000 Prentice Hall

Page 14: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 15: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 16: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

Subtype Entities“an entity that contains option sets

of attributes”

Page 56Figure 3-10b © 2000 Prentice Hall

Page 17: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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)

Page 18: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

18

Classroom Assignment

Course

Time Slots

Classroom ClassroomAssignment

1

M

1

1M

M

Convert a ternary relationship to three binary relationships

Page 19: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

Relationships“associations between entities”

Page 51Figure 3-3 © 2000 Prentice Hall

Page 20: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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.

Page 21: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

21

Connectivity and Cardinality

Professor teaches Course

Connectivity

1 M

(0,3) (1,1)

Mandatory entityOptional entity

Cardinality

Page 22: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 23: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 24: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 25: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 26: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

26

Sales Order Form

Page 27: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

27

An E-R Model for Order Processing:

ProductNumber

Description

Customer Name

Address

Unit priceQuantity

OrderNumber Date

S NameS ID

Orders

Total

Page 28: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

28

An E-R Model for Order Processing: Entities

ProductsCustomer

Orders

Salesman

Page 29: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

29

An E-R Model for Order Processing: Relationships

ProductsCustomer

Orders

1

M

M

1

1

Salesman

M

OrderLine

Prepared Placed

M

1

Page 30: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 31: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

31

Crow's Foot Notation of E-R Diagram with Attributes Shown

Page 32: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

Cardinality Symbols of Relationships for ERD

Page 33: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 34: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 35: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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.

Page 36: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

36

A E-R Model for A Construction Company

Project Employee

Job class

Assignment

Page 37: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

37

A E-R Model for A Construction Company

Manager Worker

Subclass

Project Employee

Job class

Assignment

Page 38: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

38

A E-R Model for A Construction Company

Project Employee

Job class

1

M

M

M 1

1

M

Assignment

Manages

Has

1

Page 39: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 40: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

40

The Semantic Object Model

Page 41: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 42: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

42

Semantic Objects

“a named collection of attributes that sufficiently describes a distinct entity”

Student Customer Employee

Page 74

Page 43: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

43

Attributes“define the characteristics of semantic

objects”

Page 75Figure 4-2a © 2000 Prentice Hall

Page 44: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

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

Page 45: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

45

Object Instances“the occurrence of a particular semantic

object”

Page 77Figure 4-3 © 2000 Prentice Hall

Page 46: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

46

Object Identifier

“one or more object attributes that the users employ to identify object instances”

Example: CustomerID for Customer

Page 78

Page 47: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

47

Domain

“a description of an attribute’s possible values”

Page 78

Page 48: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

48

Semantic Object View“the portion of an object that is visible to

a particular application; view”

Page 79Figure 4-4 © 2000 Prentice Hall

Page 49: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

49

Highline UniversityAdministration Database Objects:

College Department Professor Student

Page 80

Page 50: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

50

Semantic Object Diagrams

Page 85Figure 4-13 (1) © 2000 Prentice Hall

Page 51: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

51

Semantic Object Diagrams

Page 85Figure 4-13 (2) © 2000 Prentice Hall

Page 52: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

52

Semantic Object Diagrams

Page 85Figure 4-13 (3) © 2000 Prentice Hall

Page 53: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

53

Semantic Object Diagrams

Page 85Figure 4-13 (4) © 2000 Prentice Hall

Page 54: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

54

Sales Order Form

Page 55: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

55

Semantic vs. E-R Model

Page 105Figure 4-34 © 2000 Prentice Hall

Page 56: 1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R

56

Semantic vs. E-R Model

Page 105Figure 4-33 © 2000 Prentice Hall