Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modeling Data The Entity Relationship Model (ER) For Database Design.

Similar presentations


Presentation on theme: "Modeling Data The Entity Relationship Model (ER) For Database Design."— Presentation transcript:

1 Modeling Data The Entity Relationship Model (ER) For Database Design

2 Purpose of E-R Model Enterprise schema Conceptual level model –Abstract model of database –Independent of DBMS Facilitates database design –E-R diagrams are used as design tools –Precedes the implementation phase Semantic model –Captures meanings & some constraints

3 Symbols used in E-R Diagram Entity – rectangle Attribute – oval Relationship – diamond Link - line

4 An entity with attributes Employee empID name salary

5 A simple relationship between two entities salary name budgetdID name Works_InDepartmentEmployee empID

6 Entity A person, place, event, object, or some “concept” in the real world –It exists and can be distinguished from other objects Entity instances are particular persons, places… –They form the extension of the entity They will be the data Entity types are categories of entities –They form the intension of the entity They are the permanent definition part –Entity sets are collections of entities of the same type They must be well-defined

7 Attribute Defining properties or characteristics of an entity type A domain is the set of allowable values for an attribute Attributes may be –simple –composite – off-shoot ovals –null –multi-valued – double oval –Derived – broken oval

8 Relationship Connections / interactions between entity instances Relationship type – category of relationships –forms intension A relationship set is a collection of relationships of the same type A relationship instance is one that exists at a given moment –set with instances forms extension A relationship can have descriptive attributes of its own

9 Some modeling problems Painter – painting Student – teacher Patient – doctor Parent – child Husband – wife Customer – account Shopping cart – item

10 Keys Fundamental concept in database design Superkey –An attribute or set of attributes that uniquely identifies an entity Candidate key –A minimal superkey Primary key –The candidate key that is distinguished by the database designer to be used to identify entities and access records Secondary key –An attribute or set of attributes used for accessing records, but not necessarily unique Foreign key –A very important concept that we’ll study in relational model

11 About relationships Types –Binary, ternary (or more) –Recursive –Multiple Cardinalities Relationships with attributes Participation constraints Roles of entities Issues of existence dependency & weak entities

12 Types of relationships Binary – relate just two entities Ternary – relate 3 entities ABR C AB R

13 Recursive relationships Student Roommate An entity is related to itself

14 Multiple relationships Two entities with more than one relationship connecting them EmployeeDepartment Works in Manages

15 Cardinality of relationships One-to-one: Each instance of entity A is associated with at most one instance of entity B, and vice-versa One-to-many: Each instance of entity A can be associated with many instances of entity B, but each instance of entity in B is associated with at most one instance of entity A. Many-to-many: Each instance of entity A can be associated with many instances of entity B, and vice- versa ABR

16 Relationships with attributes StudentClass Enroll Grade The grade a particular student receives is associated with his/her instance of enrollment in a particular class

17 Relationship participation constraints Total participation – Fig. 3.9 ( p. 137 in hand-out ) –Every member of an entity set must participate in the relationship Use double line from entity rectangle to relationship diamond Partial participation –Not every entity instance must participate Use single line from entity rectangle to relationship diamond

18 Roles A role is the function that an entity plays in a relationship Optional to name role of each entity, but helpful in cases of –Recursive relationship – entity set relates to itself –Multiple relationships between same entity sets

19 Existence dependency An entity Y is existence dependent on another entity X if each instance of Y must have a corresponding instance of X If so, then Y must have total participation in its relationship with X EmployeeDependent R

20 ER Diagram Example See Figure 3.12, p. 141 in hand-out


Download ppt "Modeling Data The Entity Relationship Model (ER) For Database Design."

Similar presentations


Ads by Google