480 likes | 709 Views
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.
E N D
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. • A diagrammatic technique for displaying an ER model. 2
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. 3
Concepts of the Entity-Relationship Model • Entity types • Relationship types • Attributes 5
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. 7
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. 9
Diagrammatic Representation of Strong and Weak Entity Types 10
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. 11
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. 12
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. 13
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. 14
Diagrammatic Representation of Entities and their Attributes 15
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. 16
Keys • Composite Key • A candidate key that consists of two or more attributes. (Advert entity – Property_no + Newspaper_name + Date_advert) 17
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.
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. 18
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. 19
Diagrammatic Representation of Entities, Relationships, and Primary Key Attributes 21
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). 28
Structural Constraints • Participation Constraints (Identifying relationship) • Determines whether the existence of an entity depends on its being related to another entity through the relationship. 29
Identifying Relationshipvs.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 Relationshipvs.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 inan associative entity called Project-Organization.
Participation Constraints • Total (Mandatory) –connected by a double line. • Partial (Optional) – connected by a single line.
Newspaper Advertises Property_for_Rent (M:N) Relationship 35
Types of Associations 1:1 1:1 1,M 0,1 0,M 1,1 1,1 0.1 1,M 1.M
Participation Constraints of Branch IsAllocated Staff Relationship 36
Displaying Participation Constraints using (Min, Max) Notation Relationship: 5:N Branch ------------------- Staff ------------------ 0:1 37
Relationship Branch Branch # (PK) Branch Tel # 2 123-4567 234-5678 3 Staff Staff # (PK) Staff Name Branch # (FK) 2 John 101 Dean 102
A Hierarchy of Models Subject Level Denormalized Entity Normalized Entity
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. 38
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. 39