Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
157 views

Advanced Data Model

The document discusses advanced data modeling concepts including: 1) Entity supertypes and subtypes which allow entities to be related in a generalization hierarchy based on specialization, with supertypes containing common characteristics and subtypes containing unique characteristics. 2) Specialization hierarchies depict the arrangement of supertypes and subtypes in a "IS-A" relationship where subtypes can only exist within the context of their supertype. 3) Inheritance enables subtypes to inherit attributes and relationships from their supertype.

Uploaded by

shemse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views

Advanced Data Model

The document discusses advanced data modeling concepts including: 1) Entity supertypes and subtypes which allow entities to be related in a generalization hierarchy based on specialization, with supertypes containing common characteristics and subtypes containing unique characteristics. 2) Specialization hierarchies depict the arrangement of supertypes and subtypes in a "IS-A" relationship where subtypes can only exist within the context of their supertype. 3) Inheritance enables subtypes to inherit attributes and relationships from their supertype.

Uploaded by

shemse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

Chapter 6

Advanced Data Modeling

1
Entity Supertypes and Subtypes

 Generalization hierarchies allow entity types to


be related by the level of specialization.
 Entity supertype
 Generic entity type that is related to one or more
entity subtypes
 Contains common characteristics

 Entity subtypes
 Contains unique characteristics of each entity subtype

2
Specialization Hierarchy
 Depicts arrangement of higher-level entity
supertypes (parent entities) and lower-level
entity subtypes (child entities)
 Relationships sometimes described in terms of
“IS-A” relationships
 Subtype can exist only within context of
supertype and every subtype can have only one
supertype to which it is directly related
 Can have many levels of supertype/subtype
relationships
3
Entity Supertypes and Subtypes
(continued)

4
Specialization Hierarchy (continued)

5
Inheritance
 Enables entity subtype to inherit attributes and
relationships of supertype
 All entity subtypes inherit their primary key
attribute from their supertype
 At implementation level, supertype and its
subtype(s) depicted in specialization hierarchy
maintain a 1:1 relationship

6
Inheritance (continued)

7
Subtype Discriminator

 The attribute in supertype entity that determines


to which entity subtype each supertype
occurrence is related
 The default comparison condition for subtype
discriminator attribute is equality comparison

8
Disjoint and Overlapping Constraints

 Disjoint subtypes
 Alsoknown as non-overlapping subtypes
 Subtypes that contain unique subset of
supertype entity set
 Overlapping subtypes
 Subtypes that contain nonunique subsets of
supertype entity set

9
Completeness Constraint

 Specifies whether each entity supertype


occurrence must also be member of at
least one subtype
 Can be partial or total

10
Disjoint and Overlapping Constraints
(continued)

11
Sample implementation of generalization hierarchy

CREATE TABLE Employee (


EmpNo LONG NOT NULL,
EmpName VARCHAR,
EmpHireDate DATE,
CONSTRAINT PKEmployee PRIMARY KEY (EmpNo)
)
CREATE TABLE SalaryEmp (
EmpNo LONG NOT NULL,
EmpSalary DECIMAL(10,2),
CONSTRAINT PKSalaryEmp PRIMARY KEY (EmpNo),
CONSTRIANT FKSalaryEmp FOREIGN KEY (EmpNo) REFERENCES Employee ON
DELETE CASCADE
)
CREATE TABLE HourlyEmp (
EmpNo LONG NOT NULL,
EmpRate DECIMAL(10,2),
CONSTRAINT PKHourlyEmp PRIMARY KEY (EmpNo),
CONSTRIANT FKHourlyEmp FOREIGN KEY (EmpNo) REFERENCES Employee
ON DELETE CASCADE
)

12
Natural Keys and Primary Keys
 Natural key or natural identifier is a real-
world, generally accepted identifier used to
uniquely identify real-world objects

13
Primary Key Guidelines

14
When to Use Composite
Primary Keys
 Useful as identifiers of composite entities,
where each primary key combination is
allowed only once in M:N relationship
 Automatically provides benefit of ensuring that
there cannot be duplicate values
 Useful as identifiers when an identifying
relationship exists.

15
When to Use Composite Primary Keys
(continued)

16
When To Use Surrogate Primary Keys
 Surrogate key- A system assigned primary key,
generally numeric and auto-incremented
 Especially helpful when there is:
 No natural key
 Selected candidate key has embedded semantic
contents
 Selected candidate key is too long or cumbersome
 If you use surrogate key, ensure that candidate
key of entity in question performs properly
through use of “unique index” and “not null”
constraints
17
Reading recommendation

 View Design and Integration


 Mannino, from page-291

18

You might also like