Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson,...

28
Chapter 2 Chapter 2 Data Modeling Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

Transcript of Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson,...

Page 1: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

Chapter 2Chapter 2Data ModelingData Modeling

Fundamentals of Database Management Systems, 2nd ed

by

Mark L. Gillenson, Ph.D.

University of Memphis

John Wiley & Sons, Inc.

Page 2: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

22-2-2

Chapter ObjectivesChapter Objectives

Explain the concept and practical use of data Explain the concept and practical use of data modeling.modeling.

Recognize which relationships in the business Recognize which relationships in the business environment are unary, binary, and ternary environment are unary, binary, and ternary relationships.relationships.

Describe one-to-one, one-to-many, and many-Describe one-to-one, one-to-many, and many-to-many unary, binary, and ternary relationships.to-many unary, binary, and ternary relationships.

Page 3: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-33

Chapter ObjectivesChapter Objectives

Recognize and describe intersection data.Recognize and describe intersection data.

Model data in business environments by Model data in business environments by drawing entity-relationship diagrams that drawing entity-relationship diagrams that involve unary, binary, and ternary involve unary, binary, and ternary relationships.relationships.

Page 4: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-44

Essence of Data ModelingEssence of Data Modeling

Exploring the different ways that entities Exploring the different ways that entities can relate to each other as they always do can relate to each other as they always do in the real worldin the real world

Devising a way of recording, of Devising a way of recording, of diagramming, the entities and the ways in diagramming, the entities and the ways in which they interrelate in the business which they interrelate in the business environmentenvironment

Page 5: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-55

Entity-Relationship (E-R) Entity-Relationship (E-R) ModelModel

A diagramming techniqueA diagramming technique

Diagrams entities (with attributes) and the Diagrams entities (with attributes) and the relationship between the entities.relationship between the entities.

There are many variations of E-R There are many variations of E-R diagrams in use.diagrams in use.

Page 6: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-66

E-R Model Entity (and its E-R Model Entity (and its attributes)attributes)

Rectangular shapeRectangular shape

Salesperson = a type of entitySalesperson = a type of entity

Name of entity is in caps above the separator line.Name of entity is in caps above the separator line.

Page 7: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-77

E-R Model Entity (and its E-R Model Entity (and its attributes)attributes)

Entity type’s attributes are shown below the separator Entity type’s attributes are shown below the separator line.line.

PK and boldface denote the attribute(s) that constitute PK and boldface denote the attribute(s) that constitute the entity type’s the entity type’s unique identifierunique identifier..

Page 8: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-88

RelationshipsRelationships

Associations between entitiesAssociations between entities

Different kinds:Different kinds: Binary relationshipsBinary relationships Unary relationshipsUnary relationships Ternary relationshipsTernary relationships

Page 9: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-99

Binary RelationshipsBinary Relationships

Simplest kind of relationshipSimplest kind of relationship Relationship between two entity typesRelationship between two entity types A salesperson “sells” products or products are “sold” by A salesperson “sells” products or products are “sold” by

salespersonssalespersons

Page 10: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1010

CardinalityCardinality

Represents the maximum number of Represents the maximum number of entities that can be involved in a particular entities that can be involved in a particular relationship.relationship. One-to-One Binary RelationshipOne-to-One Binary Relationship One-to-Many Binary RelationshipOne-to-Many Binary Relationship Many-to-Many Binary RelationshipMany-to-Many Binary Relationship

Page 11: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1111

One-to-One Binary One-to-One Binary RelationshipRelationship

1-11-1

A single occurrence of one entity type can A single occurrence of one entity type can be associated with a single occurrence of be associated with a single occurrence of the other entity type and vice versa.the other entity type and vice versa.

Page 12: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1212

One-to-Many Binary One-to-Many Binary RelationshipRelationship

1-M1-M

Use “crow’s foot” to represent the multiple Use “crow’s foot” to represent the multiple association.association.

““many” = the maximum number of many” = the maximum number of occurrences that can be involved, means occurrences that can be involved, means a number that can be 1, 2, 3, ... n.a number that can be 1, 2, 3, ... n.

Page 13: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1313

Many-to-Many Binary Many-to-Many Binary RelationshipRelationship

M-MM-M

““many” can be either an exact number or many” can be either an exact number or have a known maximum.have a known maximum.

Page 14: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1414

CardinalityCardinality

Page 15: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1515

ModalityModality

The minimum number of entity The minimum number of entity occurrences that can be involved in a occurrences that can be involved in a relationship.relationship.

““inner” symbol on E-R diagram (“outer” inner” symbol on E-R diagram (“outer” symbol is cardinality)symbol is cardinality)

Page 16: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1616

Cardinality & ModalityCardinality & Modality

Page 17: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1717

Intersection DataIntersection Data

Describes the relationship between two entities.Describes the relationship between two entities.

Used with many-to-many relationships.Used with many-to-many relationships.

Represented on E-R diagram as an “associative Represented on E-R diagram as an “associative entity”entity”

Page 18: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1818

Many-to-Many Binary Relationship Many-to-Many Binary Relationship with Intersection Datawith Intersection Data

For example, we know not only that salesperson For example, we know not only that salesperson 137 sold some of product 24013 but also how 137 sold some of product 24013 but also how many units of that product that salesperson sold. many units of that product that salesperson sold.

Page 19: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-1919

Associative EntityAssociative Entity Entities can have attributes; many-to-many relationships Entities can have attributes; many-to-many relationships

can have attributes.can have attributes.

Many-to-many relationship may be treated similarly to Many-to-many relationship may be treated similarly to entities in an E-R diagram.entities in an E-R diagram.

Page 20: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-2020

Associative EntityAssociative Entity

The unique identifier of the associative The unique identifier of the associative entity is usually the combination of the entity is usually the combination of the unique identifiers of the two entities in the unique identifiers of the two entities in the many-to-many relationship.many-to-many relationship.

Page 21: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-2121

Unary RelationshipsUnary Relationships

Associate occurrences of an entity type Associate occurrences of an entity type with other occurrences of the same entity with other occurrences of the same entity type.type.

Cardinality:Cardinality: One-to-One Unary RelationshipOne-to-One Unary Relationship One-to-Many Unary RelationshipOne-to-Many Unary Relationship Many-to-Many Unary RelationshipMany-to-Many Unary Relationship

Page 22: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-2222

Unary Unary RelationshipsRelationships

Page 23: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-2323

Ternary RelationshipTernary Relationship

Involves three different entity types.Involves three different entity types.

Page 24: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-2424

The General Hardware The General Hardware Company E-R Company E-R DiagramDiagram

Customer Employee is Customer Employee is a dependent entity. a dependent entity.

Page 25: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-2525

Good Reading BookstoresGood Reading Bookstores

Page 26: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-2626

World Music AssociationWorld Music Association

Page 27: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-2727

Lucky Rent-A-CarLucky Rent-A-Car

Page 28: Chapter 2 Data Modeling Fundamentals of Database Management Systems, 2 nd ed by Mark L. Gillenson, Ph.D. University of Memphis John Wiley & Sons, Inc.

2-2-2828

“Copyright 2004 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976 United States Copyright Act without express permission of the copyright owner is unlawful. Request for further information should be addressed to the Permissions Department, John Wiley & Sons, Inc. The purchaser may make back-up copies for his/her own use only and not for distribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages caused by the use of these programs or from the use of the information contained herein.”