Subtype Mapping. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –State and apply the table, column, identifiers,

Slides:



Advertisements
Similar presentations
Transform an ER Model into a Relational Database Schema
Advertisements

Advanced Data Modeling
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 5/1 Copyright © 2004 Please……. No Food Or Drink in the class.
The Relational Database Model
Chapter 6 Advanced Data Modelling
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 6 Advanced Data Modeling.
Mapping an ERD to a Relational Database To map an ERD to a relational database, five rules are defined to govern how tables are constructed. 1)Rule for.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 8.
Systems Development Life Cycle
Concepts of Database Management Sixth Edition
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Mapping from E-R Model to Relational Model Yong Choi School of Business CSUB.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
Concepts of Database Management Seventh Edition
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Chapter 4 The Relational Model.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
1 Introduction to modeling Relational modelling Slides for this part are based on Chapters 11 from Halpin, T. & Morgan, T. 2008, Information Modeling and.
Database Management System Lecture 6 The Relational Database Model – Keys, Integrity Rules.
DATA MODELING AND DATABASE DESIGN
Server Design Arcs and Sub Entities.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Copyright  Oracle Corporation, All rights reserved. 4 CMIS Powell Oracle Designer: Creating the Database Design CMIS Powell.
Artificial, Composite and Secondary UIDs
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
M1G Introduction to Database Development 2. Creating a Database.
Concepts of Database Management Sixth Edition Chapter 6 Database Design 2: Design Method.
Overview of Database Development Data Modeling and Relational Database Design.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Database Design Sections 11 Database relationship, Integrity, keys, mapping conceptual model to logical/physical model Previous Section 12 – DDLesson11Fa12.ppt.
In this session, you will learn to: Map an ER diagram to a table Objectives.
Database Design Sections 11 & 12 drawing conventions, generic model, integrity, keys, mapping conceptual model to logical/physical model.
Dr Gordon Russell, Napier University Data Analysis 3 - V2.0 1 Data Analysis 3 Unit 2.3.
Data Analysis 3 Chapter 2.3 V3.0 Napier University Dr Gordon Russell.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Generic Modeling. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –Define generic modeling –Evaluate and describe.
Database Design – Lecture 4 Conceptual Data Modeling.
Defining NOT NULL and UNIQUE Constraints
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Logical Database Design and the Relational Model.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
Description and exemplification use of a Data Dictionary. A data dictionary is a catalogue of all data items in a system. The data dictionary stores details.
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 2.
Lecture 4: Logical Database Design and the Relational Model 1.
Hoi Le. Why database? Spreadsheet is not good to: Store very large information Efficiently update data Use in multi-user mode Hoi Le2.
Data Modeling Advanced Concepts Updated 20/4/2015 TMC2034 Database Concept and Design1.
Constraints Advanced Database Systems Dr. AlaaEddin Almabhouh.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Logical Database Design and the Rational Model
Database Constraints Ashima Wadhwa.
Chapter 5 Database Design
Chapter 4: Logical Database Design and the Relational Model
Chapter 4: Part B Logical Database Design and the Relational Model
Chapter 5: Logical Database Design and the Relational Model
Developing Data Models – Conversion Rules
Figure Specialization Hierarchy
Data Modelling Introduction
Constraints.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Chapter 5 Advanced Data Modeling
Mapping an ERD to a Relational Database
Introduction to modeling
Mapping an ERD to a Relational Database
Presentation transcript:

Subtype Mapping

2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –State and apply the table, column, identifiers, relationship, and integrity constraint rules for mapping supertype (single table), subtype (two table) and arc (supertype and subtype) implementations

3 home back first prev next last Why Learn It? A carpenter who is building your dream house may know that you will use different types of light bulbs all around the house. However, if you do not provide information on where certain types of light bulbs should be installed, you could end up with an overly bright bedroom and a dimly lit kitchen! Mapping supertypes and subtypes makes sure that the right information gets stored with each type.

4 home back first prev next last Supertype Implementation: Single Table This choice produces a single table for the implementation of the supertype entity and its subtypes. This is also called "single- table (or one-table) implementation." Rules –1. Tables: Only one table is created, independent of the number of subtypes. –2. Columns: The single table gets a column for all the attributes of the supertype, with the original optionality.

5 home back first prev next last Supertype Implementation: Single Table

6 home back first prev next last Supertype Implementation: Single Table –The table also gets a column for each attribute belonging to the subtype, but the columns all become optional. –Additionally, a mandatory column should be created to act as a discriminator ( 辨别者, 鉴别器 ) column to distinguish between the different subtypes of the entity. The value it can take is from the set of all the subtype short names (FTE, PTE, OTR in the example). This discriminator column is usually called _type, in the example epe_type

7 home back first prev next last Supertype Implementation: Single Table Rules –3. Identifiers: Unique identifiers transform into primary and unique keys. –4. Relationships: Relationships at the supertype level transform as usual. Relationships at subtype level are implemented as optional foreign-key columns. –5. Integrity constraints: A check constraint is needed to ensure that for each particular subtype, all columns that come from mandatory attributes are not null.

8 home back first prev next last Supertype Implementation: Single Table In the ER model, salary is mandatory for full-time employees, and hourly rate is mandatory for parttime employees. When the EMPLOYEE supertype is implemented as a single table in the relational model, these attributes become optional. A check constraint is needed to enforce the business rules modeled in the ERD. In the example, the code for the check constraint would look like this: –CHECK (epe_type = ‘FTE’ and salary is not null and hourly_rate is null and agy_id is null) OR (epe_type =‘PTE’ and salary is null and hourly_rate is not null and agy_id is not null)

9 home back first prev next last Supertype Implementation: Single Table The code checks that if it is a full-time employee (epe_type = ‘FTE’), then there must be a value in the salary column and the hourly_rate and agy_id columns must be empty. Conversely, if it is a parttime employee (epe_type = ‘PTE’), then there must be value in hourly_rate, and an agy_id, but salary must be left blank.

10 home back first prev next last Supertype Implementation: Single Table

11 home back first prev next last When Do You Choose the Single-Table/Supertype Implementation? The single-table implementation is a common and flexible implementation. It is the one you are likely to consider first and is especially appropriate where: –Most of the attributes are at the supertype level. –Most of the relationships are at the supertype level. –Business rules are globally the same for the subtypes.

12 home back first prev next last Subtype Implementation: Two Table This is also called "two-table implementation." You create a table for each of the subtypes. So, in reality, you could have more than two tables, if you had more than two subtypes. Rules –1. Tables: One table per first-level subtype. –2. Columns: Each table gets a column for all attributes of the supertype with the original optionality. –3. Each table also gets a column for each attribute belonging to the subtype, also with the original optionality.

13 home back first prev next last Subtype Implementation: Two Table –4. Identifiers: The primary UID at the supertype level creates a primary key for each table. Secondary UIDs of the supertype become unique keys in each table. –5. Relationships: All tables get a foreign key for a relationship at the supertype level, with the original optionality. For relationships at the subtype levels, the foreign key is implemented in the table it is mapped to. Original optionality is retained.

14 home back first prev next last Subtype Implementation: Two Table

15 home back first prev next last Subtype Implementation: Two Table In the example, a separate table would be created for SHIRTS and SHOES.

16 home back first prev next last When to Consider Two Table Subtype Implementation Subtype implementation may be appropriate when: –Subtypes have very little in common. There are few attributes at the supertype level and several at the subtype level. –Most of the relationships are at the subtype level. –Business rules and functionality are quite different between subtypes. –How tables are used is different -- for example, one table is being queried while the other is being updated.

17 home back first prev next last Modeling the Supertype as an Arc A supertype entity and its subtypes can be modeled as an arc relationship. Here again is the ERD with the supertype and subtypes.

18 home back first prev next last Modeling the Supertype as an Arc In this ERD, we have redrawn the CLOTHING supertype and its subtypes of SHIRT and SHOE as standalone entities with each one having mandataory 1:1 relationships with the supertype. The relationships are in an arc.

19 home back first prev next last Supertype and Subtype (Arc) Implementation This choice produces one table for every entity. The supertype table has a foreign key for each subtype table. These foreign keys represent exclusive relationships. They are optional because only one of them can have a value for each row in the table. Rules –1. Tables: As many tables are created as there are subtypes, as well as one for the supertype. –2. Columns: Each table gets a column for all attributes of the entity it is based on, with the original optionality.

20 home back first prev next last Supertype and Subtype (Arc) Implementation –3. Identifiers: The primary UID of the supertype level creates a primary key for each of the tables. All other unique identifiers become unique keys in their corresponding tables. –4. Relationships: All tables get a foreign key for a relevant relationship at the entity level, with the original optionality. –5. Integrity constraints: Two additional columns are created in the table based on the supertype. They are foreign-key columns referring to the tables that implement the subtypes. The columns are optional because the foreign keys are in an arc. An additional check constraint is needed to implement the arc. The foreign-key columns are also unique keys because they implement a mandatory 1:1 relationship.

21 home back first prev next last Supertype and Subtype (Arc) Implementation

22 home back first prev next last When to Consider Both a Supertype and Subtype (Arc) Implementation This implementation is rarely used, but it could be appropriate when: –Subtypes have very little in common and each table represents information that can be used independently. For example, when the CLOTHING table gives all global information, and both SHOES and SHIRTS give specific information, and the combination of global and specific information is hardly ever needed. –Business rules and functionality are quite different between all types. –How tables are used is different.

23 home back first prev next last Terminology Key terms used in this lesson include: –Supertype implementations –Subtype implementations –Arc implementations

24 home back first prev next last Summary In this lesson, you have learned to: –State and apply the table, column, identifiers, relationship, and integrity constraint rules for mapping supertype, subtype and arc implementations