• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Subtypes vs, roles
 

Subtypes vs, roles

on

  • 409 views

 

Statistics

Views

Total Views
409
Views on SlideShare
409
Embed Views
0

Actions

Likes
0
Downloads
7
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Subtypes vs, roles Subtypes vs, roles Document Transcript

    • Subtypes vs. RolesOne question recently posed referred to the concept of the subtype in the logical data model, thequestioner seeking to know what they are, why do we use them and what benefits they bring to thetable. Using subtypes to categorize data has always been a challenging area to the novice data modelerespecially when dealing with the concept of exclusive and inclusive subtypes. An exclusive subtype isdefined as follows: for each occurrence in the super type there can be one and only one subtypeoccurrence. Example: Party Person OrganizationThe super type Party may be sub typed as a person (or individual) or an Organization (a group ofpeople). Therefore, these subtypes are mutually exclusive, a Party can only be categorized as one or theother but never both.The inclusive subtype is defined as follows: for each occurrence in the super type there may be one tomany subtype occurrences. Example: Person Customer Employee VendorThe super type Person then may be categorized as both a Customer and an Employee. For that matter,a person could be subtyped as all three or any combination.In reality, the exclusive subtype is the form of subtyping most commonly used. Inclusive subtypes have Page 1
    • Subtypes vs. Rolesbeen used less and less overtime for the following reasons: 1. Data modelers have focused more on the semantics (the study of meaning) of data objects such as entities in the data model 2. Inclusive subtypes can create complexity and ambiguity in the data model. 3. There are inherent difficulties in defining relationships between subtype entities as well as relationships between subtype entities that are on different levels of a subtype - supertype hierarchy.Data modeling represents more than creating structures for databases. A logical data model must alsocapture clear definitions of data objects, the relationships between data objects and the relatedbusiness rules. Identifying Customer as a subtype of person upon reflection does not accurately reflectthe semantic differences between Person and Customer. A Person is a unique human being, a singlephysical object. A customer is a role that a person may play. In life and in business, people often playmultiple roles; a Person may play a role of a Customer for one or more businesses while being anEmployee of one or more businesses and additionally that customer may also be a Vendor providinggoods and/or services to a Customer.There then is a clearly defined difference between an entity that is in a supertype subtype hierarchy andentities that represent roles. - Entities in a supertype – subtype represent things - Entities that are role entities represent the roles/purposes that things serve.So what does this matter? It’s just semantics, right?Actually, there is a heavy price that may be paid by unclear semantics. How many tables have we seen insystems that have a Customer table, an Employee table and a Vendor table such as the one below: Page 2
    • Subtypes vs. Roles PersonCustomer Employee Vendor Customer Number: INTEGER Employee Number: NUMBER(5) Vendor Number: DECIMAL(7) Customer Name: TEXT(45) Employee First Name: VARCHAR(25) Vendor Name: VARCHAR(20) Csustomer Street Address: VARCHAR(20) Employee Middle Initial: CHAR(1) Vendor Personal First Name: VARCHAR(15) Customer City: VARCHAR(30) Employee Last Name: VARCHAR(20) Vendor Personal Middle Name: VARCHAR(15 Customer State Abbreviation: CHAR(2) Employee Address: VARCHAR(45) Vendor Personal Last Name: VARCHAR(15) Customer: NUMBER(5) Vendor Street Address: VARCHAR(35) Vendor City State Address: VARCHAR45) Vendor Zip Code: CHAR(10)The challenges abound! The inclusive subtyping tends to lead to denormalization and data duplicationAsalways, duplicated data creates challenges of synchronizing data and maintaining standardized formatsand data. The non standardization names and address create problems with sharing and comparingdata. Also, how do we determine which Employees are also Vendors to the company? Harte Hanks,Trillium … many companies have made significant profits trough offering address cleansing, namescleansing and rationalization (de duplication) services just to identify the same person in these differenttables and/or to determine the correct and most current address for a Customer who is also a Vendor?But wait, there is more!Can’t a Vendor be a Person or a Company (Organization?) Can’t a Customer be a Person or a company?What does this look like? Page 3
    • Subtypes vs. Roles Party Person Organization Employee Customer Regulator VendorWhat does this do to relationships?We have not added all of the relationships but we begin to see challenges 2 and 3 with the inclusivesubtypes. Multi subtype relationships, ambiguity and the lack of clarity abound! Page 4
    • Subtypes vs. Roles Party Person Organization Employee Customer Regulator VendorClearly if you are a believer in the KISS (Keep It Simple Stupid) principle in data modeling, this will not bea satisfactory outcome. Several other questions arise: 1. How flexible would this model be? 2. How extensible is this model? 3. How easily maintained would be the programs developed against the model?Let’s look at a role based model. Page 5
    • Subtypes vs. Roles Customer Role Address Party Vendor Role Regulator RolePhysical Address Phone Address EMail Address Employee Role Person OrganizationA much simpler model that is more semantically correct, less complex and has greater clarity. Thismodel of course is a starting point. Addresses definitely have roles. An associative entity betweenAddress and Party named Party Address Role would cover this.Semantics play an important role in developing successful supertype – subtype hierarchies. Theexclusive subtype assists in maintaining clarity and simplicity in the model. Inclusive subtypes may oftenbe indicative of roles and are better expressed in the model by using a role based approach.Hopefully, these musings will spark some thoughts. Page 6