Enhanced/Extended Relationship-Diagram Indra Budi [email protected].

41
Enhanced/Extended Relationship-Diagram Indra Budi [email protected]

Transcript of Enhanced/Extended Relationship-Diagram Indra Budi [email protected].

Enhanced/Extended Relationship-Diagram

Indra [email protected]

2 Fakultas Ilmu Komputer UI

Enhanced-ER (EER) Model ConceptsEnhanced-ER (EER) Model Concepts

Includes all modeling concepts of basic ER Additional concepts: subclasses/superclasses, specialization/generalization, categories, attribute inheritanceThe resulting model is called the enhanced-ER or Extended ER (E2R or EER) modelIt is used to model applications more completely and accurately if neededIt includes some object-oriented concepts, such as inheritance

3 Fakultas Ilmu Komputer UI

SubclassSubclass

Entity type describes:Type of entityThe entity set

Example: ‘EMPLOYEE’Employee can be sub-grouped into:

SecretaryEngineerTechnicianManager

These are called the subclass of EMPLOYEE entity type.

4 Fakultas Ilmu Komputer UI

Super-classSuper-class

EMPLOYEE entity type is the super class of engineer, secretary & technician class.Subclass represent the same mini-world entity of the superclass, but in a distinct specific role.These are also called IS-A relationships (SECRETARY IS-A EMPLOYEE, TECHNICIAN IS-A EMPLOYEE, …).Entity in a subclass must be a member of a superclass, but not vice-versa! Example…?

5 Fakultas Ilmu Komputer UI

Type inheritanceType inheritance

An entity that is member of a subclass inherits all attributes of the entity as a member of the superclass It also inherits all relationships

6 Fakultas Ilmu Komputer UI

SpecializationSpecialization

Is a process of defining a set of subclasses of an entity type (the superclass)Secretary, engineers, & technician are specialization of EMPLOYEE based on job type attribute

7 Fakultas Ilmu Komputer UI

Cont’dCont’d

May have several specialization based on different characteristicsExample, EMPLOYEE can be subclass-ed into Salaried_Employee and Hourly_Employee

8 Fakultas Ilmu Komputer UI

Fig 4.1

9 Fakultas Ilmu Komputer UI

Notations from the EER diagramNotations from the EER diagram

Subset symbol ⊂Specific attributes, or local attributesSpecific relationshipsSuperclass/subclass EMPLOYEE/Secretary resembles 1:1 relationship at the instance level, of one entity.

10 Fakultas Ilmu Komputer UI

Fig 4.2

11 Fakultas Ilmu Komputer UI

Benefit of SpecializationBenefit of Specialization

Define a set of subclasses of an entity typeEstablish additional specific attributes with each subclassEstablish additional specific relationship types between each subclass and other entity types or other subclassesRefer to the EER diagram…!

12 Fakultas Ilmu Komputer UI

GeneralizationGeneralization

Identify common features (attributes), and generalize into a superclassExample: truck & car can be generalized into VEHICLEInverse of the specialization process

13 Fakultas Ilmu Komputer UI

14 Fakultas Ilmu Komputer UI

ConstraintsConstraints

Constraints in SpecializationHierarchies & LatticesSpecialization in conceptual data modeling

15 Fakultas Ilmu Komputer UI

Predicate defined subclassesPredicate defined subclasses

Also called condition-defined subclassesConditioned by a defining predicate at the superclassExample, JobType = ‘Secretary’Place attribute name on the arc

16 Fakultas Ilmu Komputer UI

17 Fakultas Ilmu Komputer UI

User defined subclassUser defined subclass

Membership is specified individually for each entity by the userNot by any condition that may be evaluated automaticallyExample: Manager subclass

18 Fakultas Ilmu Komputer UI

Disjointness constraintsDisjointness constraints

Subclasses of a specialization must be disjointAn entity can only be at most one of the subclassLook at the EER diagramUse (d)

19 Fakultas Ilmu Komputer UI

OverlapOverlap

The same entity may be a member of more than one subclass of the specializationUse the (o)Example, a person can be:

A studentA faculty memberAn alumni

20 Fakultas Ilmu Komputer UI

21 Fakultas Ilmu Komputer UI

Completeness constraintsCompleteness constraints

Total specialization:Every entity in the superclass must be a member of some subclassExample, the Salaried_Employee and Hourly_EmployeeShown using double line

22 Fakultas Ilmu Komputer UI

Partial specialization:Allows an entity not to belong to any subclassExample:

• Manager• Job type

Use single line

23 Fakultas Ilmu Komputer UI

RulesRules

Deleting entity from a superclass deletes it also from the subclassesInserting in a superclass, when attribute defined is filled must insert to the proper subclass as wellInserting in superclass of total specialization must insert into at least one subclass

24 Fakultas Ilmu Komputer UI

Hierarchy & LatticeHierarchy & Lattice

Hierarchy: a subclass only participates in one class/subclass relationshipExample: Vehicle with Car and TrucksLattice: a subclass can participate in more than one class/subclass relationshipExample: an Engineering Manager, must be an Engineer, and also a Manager!The concept of multiple inheritance

25 Fakultas Ilmu Komputer UI

26 Fakultas Ilmu Komputer UI

Figure 4.7

27 Fakultas Ilmu Komputer UI

More Explanation of the EER DiagramMore Explanation of the EER Diagram

Leaf node: class that has no subclassesAn entity may exist in several leaves

Example, a student as Graduate_Student and a Teaching_Assistant

Multiple inheritance:Student_assistantBut the ‘Person’ attribute is only inherited once

28 Fakultas Ilmu Komputer UI

UNION Types Using CategoriesUNION Types Using Categories

Engineering_Manager has 3 distinct relation, each relation has 1 superclassIn our new case, a subclass has a single relationship with 3 distinct superclass.The subclass represent collection of objects, which we call union type or category

29 Fakultas Ilmu Komputer UI

Figure 4.8

30 Fakultas Ilmu Komputer UI

ExplanationExplanation

A category OWNER is a union subclass of COMPANY, BANK and PERSONUse the (U) symbolRegistered_Vehicle is a union subclass of Car & Truck

31 Fakultas Ilmu Komputer UI

The difference?The difference?

Engineering_Manager must exist in all three superclass: Manager, Engineer, Salaried_EmployeeOwner, must exist in only one superclassesEngineering_Manager: inherited all superclasses attributesOwner, selective attribute inheritance, depending on the superclass

32 Fakultas Ilmu Komputer UI

Partial CategoryPartial Category

Partial category, may or may not participate in the relation

33 Fakultas Ilmu Komputer UI

Total CategoryTotal Category

Must be one of the superclassesExample: A building and a lot must be a member of PROPERTYMay be represented as a generalization (d), especially when the similarity is numerous

34 Fakultas Ilmu Komputer UI

Fig 4.10

35 Fakultas Ilmu Komputer UI

Formal Definitions of EER Model (1)Formal Definitions of EER Model (1)

Class C: A set of entities; could be entity type, subclass, superclass, category.Subclass S: A class whose entities must always be subset of the entities in another class, called the superclass C of the superclass/subclass (or IS-A) relationship S/C:

S ⊆ CSpecialization Z: Z = {S1, S2,…, Sn} a set of subclasses with same superclass G; hence, G/Si a superclass relationship for i = 1, …., n.

G is called a generalization of the subclasses {S1, S2,…, Sn} Z is total if we always have:

S1 ∪ S2 ∪ … ∪ Sn = G;Otherwise, Z is partial.Z is disjoint if we always have:

Si ∩ S2 empty-set for i ≠ j;Otherwise, Z is overlapping.

36 Fakultas Ilmu Komputer UI

Formal Definitions of EER Model (2)Formal Definitions of EER Model (2)

Subclass S of C is predicate defined if predicate p on attributes of C is used to specify membership in S; that is, S = C[p], where C[p] is the set of entities in C that satisfy pA subclass not defined by a predicate is called user-defined Attribute-defined specialization: if a predicate A = ci (where A is an attribute of G and ci is a constant value from the domain of A) is used to specify membership in each subclass Si in ZNote: If ci ≠ cj for i ≠ j, and A is single-valued, then the attribute-defined specialization will be disjoint.Category or UNION type T

A class that is a subset of the union of n defining superclasses D1, D2,…Dn, n>1:

T ⊆ (D1 ∪ D2 ∪ … ∪ Dn)A predicate pi on the attributes of T. If a predicate pi on the attributes of Di can specify entities of Di that are members of T. If a predicate is specified on every Di: T = (D1[p1] ∪ D2[p2] ∪…∪ Dn[pn]Note: The definition of relationship type should have 'entity type' replaced with 'class'.

37 Fakultas Ilmu Komputer UI

Alternative Diagrammatic NotationsAlternative Diagrammatic Notations

Symbols for entity type / class, attribute and relationship

Displaying attributes

Displaying cardinality ratios

Various (min, max) notations

Notations for displaying specialization / generalization

38 Fakultas Ilmu Komputer UI

ExerciseExercise1. a property or description of an entity 2. a set of possible values for an attribute.3. an object in the real world that is distinguishable

from other objects such as the green dragon toy.4. an association among two or more entities.5. a collection of similar entities such as all of the

toys in the toy department.6. a collection of similar relationships7. a key constraint that indicates that one entity

can be associated with many of another entity. 8. a key constraint that indicates that many of one

entity can be associated with many of another entity.

9. an entity that cannot be identi.ed uniquely without considering some primary key attributes of another identifying owner entity.

10. maximum number of instances of an entity that can participate in an instance of a relationship

11. is the least number of instances of an entity that can participate in an instance of a relationship

a. Domainb. Entityc. Relationshipd. Entity sete. One-to-many

relationshipf. Relationship

setg. Attributeh. Minimum

cardinalityi. Weak entityj. Maximum

cardinalityk. Many-to-many

relationship

39 Fakultas Ilmu Komputer UI

Exercise (cont.)Exercise (cont.)

40 Fakultas Ilmu Komputer UI

Exercise (cont.)Exercise (cont.)Develop ER-Diagram based on following facts !

Manufacturers have a name, which we may assume is unique, an address, and a phone numberProduct have a model number and a type (e.g., television set). Each product is made by one manufacturer, and different manufacturers may have different products with the same model number. However, you may assume that no manufacturer would have two products with the same model number.Customers are identified by their unique social security number. They have email addresses, and physical addresses. Several customers may live at the same (physical) address, but we assume that no two customers have the same email address.An order has a unique order number, and a date. An order is placed by one customer. For each order, there are one or more products ordered, and there is a quantity for each product on the order.

41 Fakultas Ilmu Komputer UI

Exercise (cont.)Exercise (cont.)

A company database needs to store information about employees (identifed by ssn, with salary and phone as attributes), departments (identifed by dno, with dname and budget as attributes), and children of employees (with name and age as attributes). Employees work in departments; each department is managed by an employee; a child must be identi.ed uniquely by name when the parent (who is an employee; assume that only one parent works for the company) is known. We are not interested in information about a child once the parent leaves the company.Draw an ER diagram that captures that information.