Presentation is loading. Please wait.

Presentation is loading. Please wait.

PRJ566 : Project Planning and Management Converting Class Diagram to Relational Schema.

Similar presentations


Presentation on theme: "PRJ566 : Project Planning and Management Converting Class Diagram to Relational Schema."— Presentation transcript:

1 PRJ566 : Project Planning and Management Converting Class Diagram to Relational Schema

2 Database Design – Lecture 13 Object Terminology

3 3 OO Terminology  Simple Object Contains only single-valued attributes and has no attributes that refer to other objects

4 4 OO Terminology  Associative Object (Intersection Class) An object used to represent a relationship between two or more objects.

5 5 Steps to Convert from an Class Diagram to Relational 1. Make sure every table has a unique identifier (PK). 2. Simple classes become tables. Identify a unique identifier and make this a primary key. 3. Intersection class becomes a bridge table. 4. Remove derived attributes. 5. For association relationship of 1:M, add the PK of the 1 table as an FK of the M table.

6 6 Steps to Convert from an Class Diagram to Relational 5. For aggregation/composition relationships: a. Consider weak/strong entity relationships: If a weak relationship (aggregation), add the PK of the aggregate as a FK in the ‘part’ (it will not be part of the PK). If a strong relationship (composition), add the PK of the aggregate as part of a composite primary key of the ‘part’. It will also be a FK.

7 7 Steps to Convert from an Class Diagram to Relational 6. Inheritance relationship: a. Create a table for the superclass and a table for each of the subclasses (subtype tables). Unique identifier (primary key) for both tables will be the same, or b. Create a table for each subclass (include attributes from superclass in each table), or c. Create one table for the entire structure and create a new attribute to denote which type of subclass it is

8 8 Steps to Convert from an Class Diagram to Relational 6. Many-to-many associations: a. Create two base tables and a bridge table. The PKs of the base tables will be PK/FKs of the bridge table. 7. Do normalization (if necessary).

9 9 Steps to Convert from an Class Diagram to Relational Enrolment Example Should be 0..n

10 10 Steps to Convert from an Class Diagram to Relational Enrolment Example Continued

11 11 Steps to Convert from an Class Diagram to Relational Person is a supertype entity of Employee, Dependent and Beneficiary Create primary key for each table and convert Tables (option a from rules): PERSON (PERSON_ID (pk), FNAME, LNAME) EMPLOYEE (EMPL_PERSON_ID (pk), SEX, DATEOFBIRTH, ANNUAL_SALARY, ADDRESS) BENEFICIARY (BEN_PERSON_ID (pk)) DEPENDENT (DEP_PERSON_ID (pk), DATEOFBIRTH, RELATIONSHIP)

12 12 Steps to Convert from an Class Diagram to Relational Connectivity between Person supertype and each subtype (Employee, Dependent and Beneficiary is 1:1) Additional Relationships: EMPLOYEE:BENEFICIARY is M:N (we already identified an intersection table – EMPLOYEE_BENEFICIARY) EMPLOYEE:DEPENDENT is 1:M and is a strong/weak relationship (therefore add PK of 1 as a PK,FK of weak)

13 13 Steps to Convert from an Class Diagram to Relational Revised Tables: PERSON (PERSON_ID (pk), FNAME, LNAME) EMPLOYEE (EMPL_PERSON_ID (pk), SEX, DATEOFBIRTH, ANNUAL SALARY, ADDRESS) BENEFICIARY (BEN_PERSON_ID (pk)) DEPENDENT (DEP_PERSON_ID (pk), EMPL_PERSON_ID (pk, fk), DATEOFBIRTH, RELATIONSHIP) EMPLOYEE_BENEFICIARY (EMPL_PERSON_ID (pk, fk), BEN_PERSON_ID (pk, fk), PERCENT)

14 14 Steps to Convert from an Class Diagram to Relational More Tables: PLAN (PLAN_ID (pk), TITLE) CLIENT (CLIENT_ID (pk), ACCOUNT, TITLE, ADDRESS, TELEPHONE, FAX) BENEFIT (BENEFIT_ID (pk), TITLE, PREMIUM_RATE, DESCRIPTION) Relationships: PLAN: BENEFIT M:N (no intersection class on our OODM) Revised Tables: PLAN_BENEFIT (PLAN_ID (pk, fk), BENEFIT_ID (pk, fk))

15 15 Steps to Convert from an Class Diagram to Relational Enrolment Bridge Table: EMPLOYEE-BENEFIT(EMPL_PERSON_ID (pk, fk)), BENEFIT_ID (pk, fk), ENROLMENT_DATE)

16 16 Steps to Convert from an OODM to a Rose Model Final Relationships: CLIENT: EMPLOYEE 1:M PLAN: CLIENT 1:M Revised Tables: CLIENT (CLIENT_ID (pk), ACCOUNT, TITLE, ADDRESS, TELEPHONE, FAX, PLAN_ID (fk)) EMPLOYEE (EMPL_PERSON_ID (pk), SEX, DATEOFBIRTH, ANNUAL SALARY, ADDRESS, CLIENT_ID (fk))


Download ppt "PRJ566 : Project Planning and Management Converting Class Diagram to Relational Schema."

Similar presentations


Ads by Google