Super and Sub Type
- All records in an entity contain the same attributes that you've set. However in some designs an entity can have different types and each type can have unique attributes.
- Example: Let's imagine an employee. What kind of attributes would an employee have?
- We have a basic employee entity with some basic attributes attached.
- All employees in this entity will have the same four attributes: ID, first name, last name and a date of birth.
- However there will be times where we will have special employees that will have different attributes to other employees.
- Example, imagine employees at an airline, there are different types of employees including pilots, flight attendants, mechanics, accounts etc.
- A quick solution would be to include a "type" attribute to the entity.
- A "type" attribute would work for some cases, but in this case we have more problems.
- A pilot has a flying qualification and license which no other employee type has.
- An accountant has a CPA qualification that no other employee type has as well.
- When a situation like this occurs, we can use sub types to give unique attributes to those types of employees
- Each sub type (child) will automatically inherit (receive) all the attributes from the super type (parent).
- But each sub type now has unique attributes that other sub types and the parent do not have.
- Pilot and accountant have all the attributes the parent has.(ID, first name, last name, date of birth, type).
- But the pilot now also has a license and the accountant now has a CPA certificate.
No comments:
Post a Comment