Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Modeling Using the Entity-Relationship (ER) Data Model.

Similar presentations


Presentation on theme: "Data Modeling Using the Entity-Relationship (ER) Data Model."— Presentation transcript:

1 Data Modeling Using the Entity-Relationship (ER) Data Model

2 ER Model Concepts Entities and Attributes Entity Types, Value Sets, and Key Attributes Relationships and Relationship Types Structural Constraints and Roles Weak Entity Types

3 Entities An entity is a “thing” in the real world with an independent existence (conceptual or physical). Entities are specific objects or things in the mini-world that are represented in the database; for example the EMPLOYEE, DEPARTMENT, PROJECT, CAR, HOUSE etc.

4

5 Attributes Attributes are properties used to describe an entity. for example an EMPLOYEE entity may have a Name, SSN, Address, Sex, BirthOfDate.

6 Particular Entities A particular entity (specific entity) will have a value for each of its attributes; for example a specific employee entity may have Name='John Smith', SSN='123456789', Address='731 Fondren, Houston, TX', Sex='M', BirthOfDate='09-JAN-55'.

7 Types of Attributes Simple versus Composite Single-value versus Multi-valued Stored versus Derived Complex Attributes

8 Simple Attributes: Each entity has a single atomic value for the attribute; for example SSN or Age.

9 Composite Attributes: The attribute may be composed of several components; for example Address(Apt#, House#, Street, City, State, ZipCode, Country) or Name(FirstName, MiddleName, LastName). Composition may form a hierarchy where some components are themselves composite.

10 INSERT FIGURE 3.4

11 Single-valued Attributes Most attributes have a single value for a particular entity; such attributes are called single-valued. For example, Age is a single-valued attribute of person.

12 Multi-valued Attributes: An entity may have multiple values for that attribute; for example Color of a CAR or PreviousDegrees of a STUDENT. Denoted as {Color} or {PreviousDegrees}.

13 Stored VS. Derived Attributes In some cases two (or more) attribute values are related. Some attribute values can be derived from related entities. For example, The value of Age can be determined from the current date and the value of that person’s BirthOfDate.

14 Null Values In some case a particular entity may not have an applicable value for an attributes. For such situations, a special value called NULL is created.

15 Entity Types Entities with the same basic attributes are grouped or typed into an entity type. For example, the EMPLOYEE entity type and the PROJECT entity type.

16 Entity Sets The collection of all entities of a particular entity type in the database at any point in time is called an entities set. The entities set is usually referred to using the same name as the entity type.

17 INSERT FIGURE 3.6

18 An Entity Type An entity type describes the schema or intension for a set of entities that share the same structure. The collection of entities of a particular entity type are grouped into an entity set, which is also called the extension of the entity type.

19 Key Attributes of an Entities Type An attribute of an entity type for which each entity must have a unique value is called a key attribute of the entity type. For example, SSN of EMPLOYEE.

20 Key Attributes of an Entities Type A key attribute may be composite. For example, VehicleRegistrationNumber is a key of the CAR entity type with components (Number, State).

21 Key Attributes of an Entities Type An entity type may have more than one key. For example, the CAR entity type may have two keys: VehicleIdentificationNumber and VehicleRegistrationNumber(Number, State).

22 Value Sets (Domains) of Attributes Each simple attributes of an entity type is associated with a value set (or domain of values), which specifies the set of values that may be assigned to that attribute for each individual entity.

23 INSERT FIGURE 3.7

24 INSERT FIGURE 3.8

25 Relationships A relationship relates two or more distinct entities with a specific meaning; For example, EMPLOYEE John Smith works on the Product X PROJECT or EMPLOYEE Franklin manages the Research DEPARTMENT.

26 Relationship Types Relationships of the same type are grouped or typed into a relationship type. For example, the WORKS_ON relationship type in which EMPLOYEEs and PROJECTs participate, or the MANAGES relationship type in which EMPLOYEEs and DEPARTMENTs participate.

27 Relationship Types A relationship type R among n entity types E 1, E 2,…,E n defines a set of associations – or a relationship set – among entities from these Entity types.

28 Degree of a Relationship Type The degree of a relationship type is the number of participating entity types. Both MANAGES and WORKS_ON are binary relationships.

29 Relationship types More than one relationship type can exist with the same participating entity types; for example, MANAGES and WORKS_FOR are distinct relationships between EMPLOYEE and DEPARTMENT participate.

30 INSERT FIGURE 3.9

31 Relationships of Higher Degree Relationship types of degree 2 are called binary Relationship types of degree 3 are called ternary and of degree n are called n-ary In general, an n-ary relationship is not equivalent to n binary relationships

32 Binary relationship

33 Ternary relationship

34 INSERT FIGURE 3.10

35 Roles Names Each entity type that participates in a relationship type plays a particular role in the relationship. The role name signifies the role that a participating entity from the entity type plays in each relationship instance, and helps to explain what the relationship means.

36 Roles Name For example, in the WORK_FOR relationship type, EMPLOYEE plays the role of employee or worker and DEPARTMENT plays the role of department or employer.

37

38 INSERT FIGURE 3.11

39 Structural constraints on relationships : Cardinality ratio (of a binary relationship): 1:1, 1:N, N:1, or M:N. Participation constraint (on each participating entity type): total (called existence dependency ) or partial.

40 Cardinality ratios for Binary Relationships. The cardinality ratio for a binary relationship specifies the number of relationship instances that an entity can participate in. The possible cardinality ratios for binary relationship types are 1:1, 1:N, N:1, M:N.

41 Mapping Cardinalities One to oneOne to many Note: Some elements in A and B may not be mapped to any elements in the other set

42 Mapping Cardinalities Many to oneMany to many Note: Some elements in A and B may not be mapped to any elements in the other set

43 Participation Constraints The participation constraint specifies whether the existence of an entity depends on its being related to another entity via the relationship type. There are two types of participation constraints 1) total 2) partial.

44 Participation of an Entity Set in a Relationship Set n Total participation (indicated by double line): every entity in the entity set participates in at least one relationship in the relationship set l E.g. participation of loan in borrower is total  every loan must have a customer associated to it via borrower n Partial participation: some entities may not participate in any relationship in the relationship set l Example: participation of customer in borrower is partial

45 Relationships Attributes A relationship type can have attributes; for example, HoursPerWeek of WORKS_ON; its value for each relationship instance describes the number of hours per week that an EMPLOYEE works on a PROJECT.

46 Weak Entity Types An entity type that does not have a key attribute. A weak entity type must participate in an identifying relationship type with an owner or identifying entity type.

47 Weak Entity Types Entities are identified by the combination of : A partial key of the weak entity type The particular entity they are related to in the identifying entity type

48 We depict a weak entity set by double rectangles. We underline the discriminator of a weak entity set with a dashed line. payment number – discriminator of the payment entity set Primary key for payment – (loan_number, payment_number)

49 Example: Suppose that a DEPENDENT entity is identified by the dependent's first name and the specific EMPLOYEE that the dependent is related to. DEPENDENT is a weak entity type with EMPLOYEE as its identifying entity type via the identifying relationship type DEPENDENT_OF.

50

51 Alternative (min, max) notation for relationship structural constraints: Specified on each participation of an entity type E in a relationship type R. Specifies that each entity e in E participates in at least min and at most max relationship instances in R. Default (no constraint): min=0, max=n. Must have min 0, max>1. Derived from the mini-world constraints.

52 Examples (a): A department has exactly one manager and an employee can manage at most one department. Specify (1,1) for participation of DEPARTMENT in MANAGES Specify (0,1) for participation of EMPLOYEE in MANAGES

53 Examples (b): An employee can work for exactly one department but a department can have any number of employees. Specify (1,1) for participation of EMPLOYEE in WORKS_FOR Specify (0,n) for participation of DEPARTMENT in WORKS_FOR

54

55 ER DIAGRAM FOR A BANK DATABASE

56

57 ER diagram for book publisher


Download ppt "Data Modeling Using the Entity-Relationship (ER) Data Model."

Similar presentations


Ads by Google