The Entity-Relationship Model - PowerPoint PPT Presentation

About This Presentation
Title:

The Entity-Relationship Model

Description:

... traps are called fan traps and chasm traps. 37. Chapter 11 ... Chasm Trap ... Semantic Net of Restructured ER Model with Chasm Trap Removed. 43. Chapter 11 ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 46
Provided by: thomas854
Category:

less

Transcript and Presenter's Notes

Title: The Entity-Relationship Model


1
Chapter 11
  • The Entity-Relationship Model

2
ER Model
  • Conceptual Design answers
  • What are the entities and relationships?
  • What information about these entities and
    relationships should we store in the database?
  • What are the integrity constraints or business
    rules?
  • ER Model Concepts
  • Entity types
  • Relationship types
  • Attributes

3
Entity Type
  • Entity type
  • Group of objects with same properties,
    identified by enterprise as having an independent
    existence.
  • Entity occurrence (or entity instance)
  • Uniquely identifiable object of an entity type.

4
Examples of Entity Types
5
ER diagram of Staff and Branch entity types
6
Relationship Types
  • Relationship type
  • Set of meaningful associations among entity
    types.
  • Relationship occurrence
  • Uniquely identifiable association, which includes
    one occurrence from each participating entity
    type.

7
Semantic net of Has relationship type
8
ER diagram of Branch Has Staff relationship
Another notation
Has
Staff
Branch
9
Relationship Types
  • Degree of a Relationship
  • Number of participating entities in
    relationship.
  • Relationship of degree
  • two is binary
  • three is ternary
  • four is quaternary.

10
Binary and ternary relationships
Binary
Ternary
11
Quaternary relationship called Arranges
12
Relationship Types
  • Recursive Relationship
  • A relationship type where same entity type
    participates more than once in different roles.
  • Relationships may be given role names to indicate
    purpose that each participating entity type plays
    in a relationship.

13
Recursive relationship called Supervises with
role names
14
Entities associated through two distinct
relationships with role names
15
Attributes
  • Attribute
  • Property of an entity or a relationship type.
  • Attribute Domain
  • Set of allowable values for one or more
    attributes.
  • Simple Attribute
  • Attribute composed of a single component with an
    independent existence.
  • Composite Attribute
  • Attribute composed of multiple components, each
    with an independent existence.

16
Attributes
  • Single-valued Attribute
  • Attribute that holds a single value for each
    occurrence of an entity type.
  • Multi-valued Attribute
  • Attribute that holds multiple values for each
    occurrence of an entity type.
  • Derived Attribute
  • Attribute that represents a value that is
    derivable from value of a related attribute, or
    set of attributes, not necessarily in the same
    entity type.

17
Keys
  • Candidate Key
  • Minimal set of attributes that uniquely
    identifies each occurrence of an entity type.
  • Primary Key
  • Candidate key selected to uniquely identify each
    occurrence of an entity type.
  • Composite Key
  • A candidate key that consists of two or more
    attributes.

18
ER diagram of Staff and Branch entities and
their attributes
19
Entity Type
  • Strong Entity Type
  • Entity type that is not existence-dependent on
    some other entity type.
  • Weak Entity Type
  • Entity type that is existence-dependent on some
    other entity type.

20
Strong entity type called Client and weak entity
type called Preference
21
Relationship called Advertises with attributes
22
Structural Constraints
  • Main type of constraint on relationships is
    called multiplicity.
  • Multiplicity - number (or range) of possible
    occurrences of an entity type that may relate to
    a single occurrence of an associated entity type
    through a particular relationship.
  • Represents policies (called business rules)
    established by user or company.

23
Structural Constraints
  • The most common degree for relationships is
    binary.
  • Binary relationships are generally referred to as
    being
  • one-to-one (11)
  • one-to-many (1)
  • many-to-many ()

24
Semantic net of Staff Manages Branch relationship
type
One-to-one (11) relationship
25
Multiplicity of Staff Manages Branch (11)
relationship
26
Semantic net of Staff Oversees PropertyForRent
relationship type
One-to-many (1) relationship
27
Multiplicity of Staff Oversees PropertyForRent
(1) relationship type
28
Semantic net of Newspaper Advertises
PropertyForRent relationship type
Many-to-many () relationship
29
Multiplicity of Newspaper Advertises
PropertyForRent () relationship
30
Structural Constraints
  • Multiplicity for Complex Relationships
  • Number (or range) of possible occurrences of an
    entity type in an n-ary relationship when other
    (n-1) values are fixed for the other
    participating entity types.

31
Semantic net of ternary Registers relationship
with values for Staff and Branch entities fixed
32
Multiplicity of ternary Registers relationship
A staff/branch value pair registers zero or more
clients
33
Summary of multiplicity constraints
34
Structural Constraints
  • Multiplicity actually consists of two types of
    restrictions on relationships cardinality and
    participation.
  • Cardinality
  • Describes maximum number of possible relationship
    occurrences for an entity participating in a
    given relationship type.
  • Participation
  • Determines whether all (total) or only some
    (partial) entity occurrences participate in a
    relationship.

35
Multiplicity as cardinality and participation
constraints
36
Problems with ER Models
  • Problems may arise when designing a conceptual
    data model called connection traps.
  • Often due to a misinterpretation of the meaning
    of certain relationships.
  • Two main types of connection traps are called fan
    traps and chasm traps.

37
Problems with ER Models
  • Fan Trap
  • Where a model represents a relationship between
    entity types, but pathway between certain entity
    occurrences is ambiguous.
  • Chasm Trap
  • Where a model suggests the existence of a
    relationship between entity types, but pathway
    does not exist between certain entity
    occurrences.

38
An Example of a Fan Trap
  • At which branch office does staff number SG37
    work?

39
Restructuring ER model to remove Fan Trap
SG37 works at branch B003.
40
An Example of a Chasm Trap
  • At which branch office is property PA14
    available?

41
ER Model restructured to remove Chasm Trap
42
Semantic Net of Restructured ER Model with Chasm
Trap Removed
43
Entity vs. Attribute (not in the textbook)
  • Should address be an attribute of Employee or an
    entity (connected to Employee by a relationship)?
  • Depends upon the use we want to make of address
    information, the physical data model, and the
    semantics of the data
  • If we have several addresses per employee,
    address must be an entity (since attributes
    cannot be set-valued).
  • If the structure (city, street, etc.) is
    important, e.g., we want to retrieve employees in
    a given city, address must be modeled as an
    entity (since attribute values are atomic).

44
Entity vs. Attribute (not in the textbook)
  • Works_In1 does not allow an employee to
    work in a department for two or more
    periods.
  • Similar to the problem of wanting to record
    several addresses for an employee.
  • Solution Place periods in a separate entity
    type.

from to
Department did dname budget
0
11
Works_In1
Department did dname budget
0
11
Works_In2
1
Duration from to
45
Entity vs. Relationship (not in the textbook)
  • First ER diagram OK if a manager gets a separate
    budget for each dept.
  • What if a manager gets a budget that covers all
    managed depts?
  • Redundancy of dbudget, which is stored for each
    dept managed by the manager.
  • Misleading suggests dbudget tied to managed
    dept.
  • Solution Create a separate entity type Mgr_Appts.

since dbudget
Department did dname budget
11
01
Manages1
Department did dname budget
11
01
Manages2
01
Mgr_Appts apptnum since dbudget
Write a Comment
User Comments (0)
About PowerShow.com