Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Management COP4540, SCS, FIU Database Modeling Using the Entity- Relationship Model (Continued)

Similar presentations


Presentation on theme: "Database Management COP4540, SCS, FIU Database Modeling Using the Entity- Relationship Model (Continued)"— Presentation transcript:

1 Database Management COP4540, SCS, FIU Database Modeling Using the Entity- Relationship Model (Continued)

2 Database Management COP4540, SCS, FIU Usage of Weak Entities Weak Entity can be used when converting a n-ary relationship to a number of binary relationships. The basic algorithm can be found in the previous lecture note. The additional ENTITY CLASS is actually a weak entity.

3 Database Management COP4540, SCS, FIU An Example of Ternary Relationship SUPPLIERPROJECT PART SName ProjNamePartNo SUPPLY Quantity

4 Database Management COP4540, SCS, FIU Converted E-R Diagram SUPPLIERPROJECT PART SName ProjNamePartNo Quantity SUPPLY SSSPJSP 1 N 1N 1 N

5 Database Management COP4540, SCS, FIU What if defining a cardinality constraint SUPPLIERPROJECT PART SName ProjNamePartNo SUPPLY Quantity 1M N

6 Database Management COP4540, SCS, FIU Converted E-R Diagram SUPPLIERPROJECT PART SName ProjNamePartNo Quantity SUPPLY SS SPJSP 11 1N 1 N

7 Database Management COP4540, SCS, FIU Design Principles Faithfulness Avoiding redundancy Keep it simple Picking the right kind of element

8 Database Management COP4540, SCS, FIU Faithfulness Include everything needs to be described. Avoid meaningless descriptions. Enforce as many constraints as possible. –Cardinality Ratios. –Participation Constraints –Existence Dependency.

9 Database Management COP4540, SCS, FIU Cardinality Ratios The cardinality ratios for binary relationships –1:1, 1:N, N:1, and M:N Attributes of 1:1 relationship types can be migrated to either of the participating entity types. Attributes of 1:N or N:1 relationship types can be migrated only to the entity type at N-side of the relationship. Attributes of M:N relationship types must be specified as relationship attributes.

10 Database Management COP4540, SCS, FIU Examples EMPLOYEE Manages 11 Starting date DEPARTMENT EMPLOYEE Manages 11 Starting date DEPARTMENT EMPLOYEE Manages 11 Starting date DEPARTMENT

11 Database Management COP4540, SCS, FIU Examples PROJECTEMPLOYEE Works_on 1 N Hours PROJECTEMPLOYEE Works_on 1 N Hours Note: IF we assumed that each employee can only work on one project, and there may be many employees working on the same project, THEN: The attribute Hours can be migrated to EMPLOYEE, but not PROJECT.

12 Database Management COP4540, SCS, FIU Examples EMPLOYEE Works_on M N PROJECT Hours Note: IF we assume that each employee may work on multiple projects at the same time, and there may be many employees working on the same projects, THEN: The attribute Hours can not be migrated to either PROJECT or EMPLOYEE.

13 Database Management COP4540, SCS, FIU Participation Constraints It specifies whether the existence of an entity depends on its being related to another entity via relationship type. Two types –total participation (Using double line connecting the participating entity type) –partial participation Total participation is also called Existence Dependency.

14 Database Management COP4540, SCS, FIU Examples DEPARTMENT EMPLOYEE Works_for 1N Note: IF we assume that every employee should be assigned to certain department. THEN: There is a total participation constraint defined on EMPLOYEE via the relationship Works_for.

15 Database Management COP4540, SCS, FIU Examples DEPARTMENT EMPLOYEE Works_for 1N Note: IF we assume that each department should have at least one employee being assigned, THEN: There is a total participation constraint defined on DEPARTMENT via the relationship Works_for.

16 Database Management COP4540, SCS, FIU Examples DEPARTMENT EMPLOYEE Manages 11 Note: IF we assume that should have exactly one manager, but not every employee could be a manager of certain department, THEN: There is a total participation constraint defined on DEPARTMENT via the relationship type Manages. However, EMPLOYEE partially participates the relationship type Manages.

17 Database Management COP4540, SCS, FIU Alternative Notations for Constraints A pair of integer (min, max) with each participation of entity type E in a relationship type R. ( max min  0, max  1) min: at least min; max: at most max min = 0 implies partial participation. min  1 implies total participation.

18 Database Management COP4540, SCS, FIU Examples DEPARTMENT EMPLOYEE Works_for (4,N) (1,1) This example implies that each employee is assigned to one and only one department. Each department has at least four employees, and there is no upper limit of the number of employees in a department. DEPARTMENT EMPLOYEE Works_for 1 N

19 Database Management COP4540, SCS, FIU Examples DEPARTMENT EMPLOYEE Manages (0,1)(1,1) What does this example imply? DEPARTMENT EMPLOYEE Manages 11 What does this example imply?

20 Database Management COP4540, SCS, FIU Examples DEPENDENT namesex birthdate relationship EMPLOYEE Dependents_of (0,N) (1,1) SSN What does this example imply?

21 Database Management COP4540, SCS, FIU Avoiding Redundancy Problem with redundancy –Wastes space. –Encourages inconsistency. Principle: describe and store everything once only. Intuition: something is redundant if it could be hidden from view, and you could still figure out what it is from the other data.

22 Database Management COP4540, SCS, FIU Examples BEERSMANFS ManfBy name address BEERS name manf manfadd Question: Which one is better?

23 Database Management COP4540, SCS, FIU KISS: Keep It Simple, Student Avoid intermediate concepts if unnecessary. BEERSMANFS ManfBy name


Download ppt "Database Management COP4540, SCS, FIU Database Modeling Using the Entity- Relationship Model (Continued)"

Similar presentations


Ads by Google