Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model.

Similar presentations


Presentation on theme: "Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model."— Presentation transcript:

1 Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model

2 Dr. Mohamed Osman Hegazi2 ER UML Mapping Normalization Design container, policy, Integrity Create & Programming Query processing and transaction Database Administration

3 Dr. Mohamed Osman Hegaz3 Conceptual Design is an important phase in designing a successful database application. The Entity Relationship (ER) Model is one of the most widely used method for conceptual design. The ER Model can be neatly mapped to a Relational Schema. Conceptual Modeling

4 Dr. Mohamed Osman Hegaz4 Entities – Entity Sets and Entity Types – Attributes, Keys and Value Sets Relationships – Relationship Types and Sets – Relationship Degree – Roles and Recursive Relationships – Relationship Constraints – Attributes of Relationship Types ER Model Basics

5 Dr. Mohamed Osman Hegaz5 ER Diagram Basics

6 6 Defines set of entities that have the same attributes (e. g. EMPLOYEE). Each Entity Type is described by its NAME and Attributes. The Entity Type describes the “Schema” for entities. Entity Type and Entity Set are customarily referred to by the same name. Entity Type

7 Dr. Mohamed Osman Hegaz7 Key Attributes. Null Valued Attributes. Attribute Types – Composite Vs. Simple Attributes. – Single- valued Vs. Multi- valued Attributes. – Derived Vs. Stored Attributes. Notation Attributes

8 Dr. Mohamed Osman Hegaz8 Key attribute’s values are distinct for each individual extension in the entity set. A key attribute has its name underlined inside the oval. Key must hold for every possible extension of the entity type. Multiple keys are possible Key Attributes

9 Dr. Mohamed Osman Hegaz9 A particular entity may not have an applicable value for an attribute. – Phd - Degree: Not applicable for a person with no university education. – Home- Phone: Not known if it exists. – Height: Not known at present time. Type of Null Values – Not Applicable – Unknown – Missing Null Valued Attributes 29/09/2007 9

10 Dr. Mohamed Osman Hegaz10 Composite attributes can be divided into smaller parts which represent simple attributes with independent meaning. Simple Attribute: B-Date Complex Attribute: Name which is comprised of: First name Mid name Last name Composite Vs. Simple Attributes 29/09/2007 10Week_03

11 Dr. Mohamed Osman Hegaz11 Simple attributes can either be single-valued or multi- valued. Single-valued: Gender = F Notation Multivalued: Degree = {BSc, Phd} Notation An “attribute” in the relational model is always single valued - Values are atomic! Single Vs. Multivalued Attributes 11

12 Dr. Mohamed Osman Hegaz12 Some attribute values can be derived from related attribute values: Age  Date - B-day Y-Sal  12 * M-Sal Derived Vs. Stored Attributes

13 Dr. Mohamed Osman Hegaz13 Relationship Types and Sets. Relationship Degree. Entity Roles and Recursive Relationships. Relationship Constraints. Attributes of Relationship Types. Relationships

14 Dr. Mohamed Osman Hegaz14 A Relationship is an association among two or more entities (e.g. Students enroll in courses). Relationship Degree The degree of a relationship type is the number of participating entity types. 2 entities: Binary Relationship 3 entities: Ternary Relationship n entities: N-ary Relationship Same entity type could participate in multiple relationship types. Relationship Types and Sets

15 Dr. Mohamed Osman Hegaz15 Each entity type that participates in a relationship type plays a particular role in the relationship type. The role name signifies the role that a participating entity from the entity type plays in each relationship instance, i.e. it explains what the relationship means. Entity Roles

16 Dr. Mohamed Osman Hegaz16 Recursive Relationships Same entity type can participate more than once in the same relationship type under different “roles”. Such relationships are called “Recursive Relationships”.

17 Dr. Mohamed Osman Hegaz17 Kinds of Constraints What kind of constraints can be defined in the ER Model? Cardinality Constraints. Participation Constraints. Together called “Structural Constraints”. Constraints are represented by specific notation in the ER diagram. Relationship Constraints

18 Dr. Mohamed Osman Hegaz18 Cardinality Ratio The “Cardinality Ratio” for a binary relationship specifies the number of relationship instances that an entity can participate in. – Works-In is a binary relationship. – Participating entities are Department : Employee – One department can have Many employees Ratio is -Cardinality 1 : N

19 Dr. Mohamed Osman Hegaz19 Possible Cardinality Ratios 1- to- 1 (1: 1) Both entities can participate in only one relationship instance. 1- to Many Many- to- 1 (1: N, N: 1) One entity can participate in many relationship instances. Many- to- Many (N: M) Both entities can participate in many relationship instances.

20 Dr. Mohamed Osman Hegaz20 Example Cardinality Constraints How many Employees can work in a Department? Many employee can work in only one department How many Employees can be employed by a Department? One department can employ many employees How many managers can a department have? One department can have only one manager How many departments can an employee manage? One employee can have manage only one department

21 Dr. Mohamed Osman Hegaz21 Representing Cardinality Many employee can work in only one department One department can employ many employees One department can have only one manager One employee can manage only one department

22 Dr. Mohamed Osman Hegaz22 Existence Dependency Existence dependency indicates whether the existence of an entity depends on its relationship to another entity via the relationship type. Every employee must work for a department - EMPLOYEE is existentially dependent on DEPARTMENT via the Works-In relationship type.

23 Dr. Mohamed Osman Hegaz23 Kinds of participating constraints TOTAL Participation (Existence Dependency) Constraint: Every employee must work for a department. PARTIAL Participation Constraint: Not every employee is a manager.

24 Dr. Mohamed Osman Hegaz24 Representing Participation Every employee must work for a department Every department must have a manager Every department must have employees Not every employee is a manager

25 Dr. Mohamed Osman Hegaz25 Attributes of Relationship Types Relationship Types can also have attributes just as entity types.

26 Dr. Mohamed Osman Hegaz26 Weak Entities Entity types that do not have key attributes of their own are called “Weak Entities”. A weak entity can be identified uniquely only by considering the primary key of another “Owner” entity. The relationship type that relates a weak entity to its owner is called the “Identifying relationship”.

27 Dr. Mohamed Osman Hegaz27 Weak Entities Owner and weak entity must participate in a 1: N relationship type. Weak entity must have total participation in the identifying relationship set (existence dependency). Weak entities normally have a “Partial Key”, which is a set of attributes that uniquely identify weak entities related to the same owner entity. Not every existence dependency results in a weak entity !

28 Dr. Mohamed Osman Hegaz28 Example Weak Entity

29 Dr. Mohamed Osman Hegaz29 Week_03 SUMMARY OF ER-DIAGRAM

30 Dr. Mohamed Osman Hegaz30 Exercises: Q1: Describe what entity types represent in an ER model. Q2: Describe what relationship types represent in an ER model. Q3: Describe what attributes represent in an ER model. Q4: Create an ER Diagram for each of the following descriptions:  Each company operates four departments, and each department belongs to one company.  Each department in part (a) employs one or more employees, and each employee works for one department.  Each of the employees in part (b) may or may not have one or more dependant, and each dependant belongs to one employee.  Each employee in part (c) may or may not have employment history.  Represent all ER diagrams described in (a), (b), (c), and (d) as single ER daigarm

31 Dr. Mohamed Osman Hegaz31 Q5: Consider the company example, on ER diagram:  List the (nonweak ) entity type in the ER.  Is there weak entity type? If so give its name.  List the names of all relation types, and specify the cardinality ratio.  Is there recursive relationship? If so give its name.


Download ppt "Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model."

Similar presentations


Ads by Google