0% found this document useful (0 votes)
35 views35 pages

CH 02

Uploaded by

Bryan alex
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views35 pages

CH 02

Uploaded by

Bryan alex
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

Modern Database Management

Thirteenth Edition, Global Edition

Chapter 2
Modeling Data in the
Organization

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Learning Objectives
2.1 Define terms
2.2 Write good names and definitions for entities, relationships,
and attributes
2.3 Distinguish unary, binary, and ternary relationships
2.4 Model different types of attributes, entities, relationships, and
cardinalities
2.5 Convert many-to-many relationships to associative entities

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Entities
• Entity
– a person, a place, an object, an event, or a concept in
the user environment about which the organization
wishes to maintain data
• Entity type
– a collection of entities that share common properties or
characteristics, often corresponds to a table, slide 4
• Entity instance
– a single occurrence of an entity type, often
corresponds to a row in a table, slide 5

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Entity Type and Entity Instances
FIGURE 2-3 Entity type EMPLOYEE with two instances

Entity type: EMPLOYEE

Attributes Attribute Data Type Example Instance Example Instance


Employee Number CHAR (10) 64217836 53410197
Name CHAR (25) Michelle Brady David Johnson
Address CHAR (30) 100 Pacific Avenue 450 Redwood Drive
City CHAR (20) San Francisco Redwood City
State CHAR (2) CA CA
Zip Code CHAR (9) 98173 97142
Date Hired DATE 03-21-1992 08-16-1994
Birth Date DATE 06-19-1968 09-04-1975

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Entity Instances

1st entity instance

Emp-ID Name Address City Stat Zipcode Date-hired DOB


e
53410197 David 450 Redwood San CA 97142 08-16-1994 09-04-1975
Johnson Drive Francisco

64217836 Michelle 100 Pacific Redwood CA 98173 03-21-1992 06-19-1968


Brady Avenue City

2nd entity instance

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Entity Relationship(ER) Model
• Entity relationship model
– is a logical representation of the data for an organization
– it is expressed in terms of entities in the business
environment, the relationships among the entities and the
attributes of both entities and their relationships
– it is commonly expressed as an entity-relationship diagram
(E-R diagram), slide 7
• Relationship:
– an association representing an interaction among the
instances of one or more entity types
• Attributes:
– properties or characteristics of an entity

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-21 Example of Multiple
Relationships
a) Employees and departments

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-1 Sample E-R Diagram

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Copyright © 2020 Pearson Education Ltd. All Rights Reserved
Business Rules
• Statements that define or constrain aspect of the
business activities
• Derived from business policies, procedures, events, or
functions
• They govern the creating, updating, and removing data in
an information system
• Intended to control the business behaviors
• Are expressed in terms that are familiar to end users
• They are stored in a central repository and shared
throughout the organization

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Strong v s. Weak Entities, and Identifying
ersu

Relationships
• Strong entity
– exists independently of other types of entities
– has its own unique identifier
▪ identifier underlined with single line, slide 12
• Weak entity
– dependent on a strong entity (identifying owner); cannot exist on
its own
– does not have a unique identifier (only a partial identifier)
– entity box and partial identifier have double lines
• Identifying relationship
– links strong entities to weak entities

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-5 Example of a Weak Identity and
Its Identifying Relationship
Weak entity with identifying relationship.

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Attributes
• Attribute – property or characteristic of an entity or
relationship type
• Classifications of attributes:
– Identifier
– Required versus Optional
– Simple versus Composite
– Single-Valued versus Multivalued
– Stored versus Derived

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Identifiers (Keys)
• Identifier (Key) – an attribute (or combination of
attributes) that uniquely identifies individual instances of
an entity type
• Simple identifier, slide 14
– An identifier which is formed by only one attribute, e.g.
Employee ID or Student ID

• Composite identifier
– An identifier which is formed by more than one attribute, e.g.
Flight ID

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-9 Simple and Composite Identifier
Attributes
a) Simple identifier attribute

b) Composite identifier attribute

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Required versus Optional Attributes
Entity type: STUDENT
Attributes Attribute Required or Example Example Instance
Data Type Optional Instance
Student I D CHAR (10) Required 28-618411 26-844576
Student Name CHAR (40) Required Michael Grant Melissa Kraft
Home Address CHAR (30) Required 314 Baker St. 1422 Heft Ave
Home City CHAR (20) Required Centerville Miami
Home State CHAR (2) Required OH FL
Home Zip Code CHAR (9) Required 45459 33321
Major CHAR (3) Optional MI S Blank

Required – must have a value for every entity (or relationship) instance with
which it is associated

Optional – may not have a value for every entity (or relationship) instance with
which it is associated
Copyright © 2020 Pearson Education Ltd. All Rights Reserved
Simple versus Composite Attributes
• Simple – an attribute that cannot be broken down into
smaller components
• Composite – An attribute that has meaningful
component parts (sub-attributes)

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Single-valued versus Multivalued attributes

• Single-valued: an attribute has only one value


• Multivalued
– May take on more than one value for a given entity
(or relationship) instance
– An employee can have more than one skill

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Stored versus Derived Attributes
• Stored
– An attribute which has a value stored already
• Derived
– Values can be calculated from related attribute values
(not physically stored in the database)
– Years employed calculated from date employed and
current date

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Modeling Relationships
• Relationship Types v s. Relationship Instances
ersu

– The relationship type is modeled as lines between


entity types. The relationship instance is between
specific entity instances, slide 21
• Relationships can have attributes
– These describe features pertaining to the association
between the entities in the relationship
• Two entities can have more than one type of relationship
between them (multiple relationships)

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-10 Relationship Type and
Instances
a) Relationship
type (Completes)

b) Relationship
instances

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Degree of Relationships
• Degree of a relationship is the number of entity types that
participate in it
– Unary Relationship, slide 23
– Binary Relationship
– Ternary Relationship

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


From Figure 2-2 Degrees of Relationships
• Unary( 單元 ) – entities of the same type related to each other
• Binary( 雙元 ) – entities of one type related to entities of another
• Ternary( 三元 ) – entities of three different types involved in the same
relationship

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-12 Examples of Relationships of
Different Degrees (1 of 3)
a) Unary relationships

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Cardinality of Relationships
• One-to-One
– Each entity in the relationship will have exactly one
related entity
• One-to-Many
– An entity on one side of the relationship can have
many related entities, but an entity on the other side
will have a maximum of one related entity
• Many-to-Many
– Entities on both sides of the relationship can have
many related entities on the other side

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-12 Examples of Relationships of
Different Degrees (2 of 3)
b) Binary relationships

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-12 Examples of Relationships of
Different Degrees (3 of 3)
c) Ternary relationships

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Cardinality Constraints
• Cardinality Constraints — the number of instances of one
entity that can or must be associated with each instance
of another entity
• Minimum Cardinality
– If zero, then optional cardinality
▪ Optional One and Optional Many, slide 29, 30
– If one or more, then mandatory cardinality
▪ Mandatory One and Mandatory Many, slide 31, 30

• Maximum Cardinality
– The maximum number of instances of an entity that
may be associated with each instance of another
entity

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-17 Examples of Cardinality
Constraints (3 of 3)
c) Optional cardinalities

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-17 Examples of Cardinality
Constraints (2 of 3)
b) One mandatory, one optional cardinality

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-17 Examples of Cardinality
Constraints (1 of 3)
a) Mandatory cardinalities

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Associative Entities
• Associative entity: a table that associates two other tables in a
many to many relationship.
• When should a relationship with attributes be an associative
entity?
– All relationships for the participating entity types should be
‘many’ relationships
– The associative entity could have meaning independent of
the other entities
– The associative entity preferably has a unique identifier,
and should also have other attributes
– Convert ternary relationships to associative entities

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-11 Associative Entities
An associative entity is an entity. It has attributes. It is also a relationship. It
serves to link other entities together in a many-to-many relationship.

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-13 Representing a Bill-of-
Materials Structure (1 of 2)
Two ways to represent a bill-of-materials structure

Copyright © 2020 Pearson Education Ltd. All Rights Reserved


Figure 2-13 Representing a Bill-of-
Materials Structure (2 of 2)
A bill-of-materials is a hierarchy of items. Here, bikes are composed of handle
bars, transmissions, wheels, etc. Transmissions include their own sub-parts,
brakes and derailers.

Copyright © 2020 Pearson Education Ltd. All Rights Reserved

You might also like