chapter 11
DESCRIPTION
Chapter 11. Entity-Relationship modeling Transparencies. Chapter 11 - Objectives. The use of high-level conceptual data models to support database design. The basic concepts associated with the Entity-Relationship (ER) model, a high-level conceptual data model. - PowerPoint PPT PresentationTRANSCRIPT
Chapter 11
Entity-Relationship modelingTransparencies
2
Chapter 11 - Objectives The use of high-level conceptual data
models to support database design.
The basic concepts associated with the Entity-Relationship (ER) model, a high-level conceptual data model.
A diagrammatic technique for displaying an ER model.
3
Chapter 11 - Objectives How to identify problems called
connection traps, which may occur when creating an ER model.
The limitations of the basic ER modeling concepts and the requirements to model more complex applications using enhanced data modeling concepts.
5
Concepts of the Entity-Relationship Model
Entity types
Relationship types
Attributes
7
Entity Type Entity Type
– An object or concept that is identified by the enterprise as having an independent existence.
Entity– An object or concept that is
uniquely identifiable.
8
Examples of Entity Types
9
Entity Type
Weak Entity Type (dependent entity)– An entity type that is existence-dependent on
some other entity type (parent vs child entity).
Strong Entity Type (independent entity) – An entity type that is not existence-dependent on
some other entity type.
10
Diagrammatic Representation of Strong and Weak Entity Types
11
Attributes Attribute
– A property of an entity or a relationship type.
Attribute Domain– A set of values that may be
assigned to a single-valued attribute.
12
Attributes
Simple Attribute (Salary)– An attribute composed of a single
component with an independent existence.
Composite Attribute (Address)– An attribute composed of multiple
components each with an independent existence.
13
Attributes Single-valued Attribute (Branch
Number)– An attribute that holds a single-
value for a single entity.
Multi-valued Attribute (Tel_No)– An attribute that holds multiple
values for a single entity.
14
Attributes Derived Attribute
– An attribute that represents a value that is derivable from the value of a related attribute or set of attributes, not necessarily in the same entity.
15
Diagrammatic Representation of Entities and their Attributes
16
Keys Candidate Key
– An attribute or set of attributes that uniquely identifies individual occurrences of an entity type.
Primary Key– An entity type may have one or more
possible candidate keys, one of which is selected to be the primary key.
17
Keys Composite Key
– A candidate key that consists of two or more attributes. (Advert entity – Property_no +
Newspaper_name + Date_advert)
Primary vs Foreign Keys Rule: Primary keys are Indicated by the letters PK under the
appropriate column heading(s) Rule: Primary keys must never be null (PK implies NN) Rule: Primary key column may not contain duplicate values (PK
implies ND)
Foreign Key Rule: Foreign keys are Indicated by the letters FK under the
appropriate column heading(s)
Primary Key Selection
Select Primary keys that are not likely to change. Select Primary keys that are short. Select Primary keys that are numeric.
Select Primary keys that are familiar to the system user.
18
Relationship Types Relationship Type
– A meaningful association among entity types.
Relationship (1:1; 1: M; M:M)– An association of entities where
the association includes one entity from each participating entity type.
19
Relationship Types Degree of a Relationship
– The number of participating entities in a relationship.
Recursive Relationship– A relationship where the same
entity participates more than once in a different roles.
21
Diagrammatic Representation of Entities, Relationships, and Primary Key Attributes
22
Binary Relationship called Owns
23
Ternary Relationship called SetsUp
24
Quaternary Relationship called Arranges
25
Recursive Relationship called Supervises
26
Entities associated through two distinct Relationships
27
Relationship called Views with attributes
28
Structural Constraints Two main types of restrictions on
relationships are cardinality and participation constraints.
Cardinality Constraints (Ratio) (non-identifying) – Determines the number of possible
relationships for each participating entity.– Most common degree for relationships is binary with
cardinality ratios of one-to-one (1:1), one-to-many (1:M) or many-to-many (M:N).
29
Structural Constraints Participation Constraints
(Identifying relationship)– Determines whether the
existence of an entity depends on its being related to another entity through the relationship.
Identifying Relationship vs.Non-Identifying Relationship
Identifying Relationship An identifying relationship is a relationship between
two entities in which primary key of one entity appears as a foreign key in the other entity as a key data element or set of data elements. For example, the relationship between parent entity and child entity is an identifying relationship.
Identifying Relationship vs.Non-Identifying Relationship
Non-Identifying Relationship
A non-identifying relationship is a relationship between two entities in which the primary key of one entity appears as a foreign key in the other entity as a non-key data element. For example, the relationship between an Organization entity and a Project entity is a non-identifying relationship. Additionally, the Organization identifier appears as a foreign key (as an element), but not part of the primary key in the Project entity.
Types of Entities Independent Entity (Fundamental entity)
An independent entity is a group of data that exists without dependence upon any other entity. Therefore it does not have any identifying parent(s). Its primary key does not contain a foreign key from any other entity
Dependent Entity (Attribute Entity)
A dependent entity (or child entity) is a group of data that cannot exist without the support of another entity (or parent entity). Its primary key contains a foreign key from another entity.
Types of Entities
Associative Entity
An associative entity is an entity that exists when decomposing a many-to-many relationship between two entities. For example, a many-to-many relationship between an entity called Project and another called Organization would result in an
associative entity called Project-Organization.
Participation Constraints Total (Mandatory) –connected by a
double line. Partial (Optional) – connected by a
single line.
31
Staff Manages Branch (1:1) Relationship
33
Staff Oversees Property_for_Rent (1:M) Relationship
35
Newspaper Advertises Property_for_Rent (M:N) Relationship
Types of Associations
0,1
1,M
1,1 0,M
1,1 0.1
1.M 1,M
1:1 1:1
36
Participation Constraints of Branch IsAllocated Staff Relationship
37
Displaying Participation Constraints using (Min, Max) Notation
Relationship: 5:N Branch ------------------- Staff ------------------ 0:1
RelationshipBranch
Staff
Branch #(PK)
Branch Tel #
2
3
123-4567
234-5678
Staff #(PK)
Staff Name Branch # (FK)
101 John 2
102 Dean
A Hierarchy of Models
Subject Level
Entity
DenormalizedEntity
Normalized
38
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.
39
Problems with ER Models Fan Trap
– When a model represents a relationship between entity types, but the pathway between certain entity occurrences is ambiguous.
Chasm Trap– When a model suggests the existence of a
relationship between entity types, but the pathway does not exist between certain entity occurrences.
40
An Example of a Fan Trap
42
Restructuring ER model to remove Fan Trap
44
An Example of a Chasm Trap
46
ER Model restructured to remove Chasm Trap