CSC 742 Database Management Systems Phases ... - Dr. Peng Ning
CSC 742 Database Management Systems Phases ... - Dr. Peng Ning
CSC 742 Database Management Systems Phases ... - Dr. Peng Ning
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>CSC</strong> <strong>742</strong><br />
<strong>Database</strong> <strong>Management</strong> <strong>Systems</strong><br />
Topic #4: Data Modeling<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 1<br />
<strong>Phases</strong> of <strong>Database</strong> Design<br />
Requirement Collection/Analysis<br />
Functional Requirements<br />
Functional Analysis<br />
High-Level Transaction Spec.<br />
Application Program Design<br />
Transaction Implementation<br />
<strong>Database</strong> Requirements<br />
Conceptual Design<br />
Conceptual Schema<br />
Logical Design<br />
Logical Schema<br />
Physical Design<br />
Application Program<br />
Internal Schema<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 2<br />
1
¡<br />
¡<br />
¡<br />
¡<br />
¡<br />
Part A: Entity-Relationship<br />
Model<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 3<br />
What is ER Model About<br />
Structure of the data<br />
Entities and relationships between (among)<br />
entities<br />
Constraints<br />
Conditions that the entities and relationships<br />
must satisfy.<br />
Key constraint<br />
Domain constraint<br />
Structural constraint<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 4<br />
2
ER Concepts<br />
Entities<br />
Relationships<br />
Attributes<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 5<br />
Attributes<br />
Atomic vs. composite<br />
Single- vs. multivalued<br />
Stored vs. derived<br />
Complex Attributes<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 6<br />
3
¡<br />
¡<br />
¡<br />
Null Values<br />
Need<br />
Meanings<br />
not applicable<br />
unknown: missing or questionable<br />
existence<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 7<br />
Entities<br />
Entity type (intension): e.g., Employee or<br />
Dept<br />
A collection of entities that have the same<br />
attributes<br />
Entity instance: e.g., Fred or Payroll<br />
Entity set (extension): e.g., {Fred, Bob, ...}<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 8<br />
4
Keys<br />
An intension corresponds to all possible<br />
extensions<br />
Superkey: a set of attributes that are unique<br />
for an entity type (i.e., for all possible<br />
extensions)<br />
Key: a minimal superkey—fewer attributes<br />
won't be unique<br />
An entity type may have multiple keys<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 9<br />
Relationships<br />
Relationship types: e.g., works-in<br />
Relationship instances: e.g., Fred works-in<br />
Payroll<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 10<br />
5
Relationship Properties<br />
A relationship type<br />
associates entity types<br />
typically binary or ternary<br />
recursive<br />
may have attributes<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 11<br />
Entity Types<br />
Participate in relationship types<br />
Have roles in those relationship types<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 12<br />
6
Cardinality<br />
Cardinality constraints: number of<br />
relationship instances in which an entity<br />
instance may feature<br />
1:1<br />
1:N<br />
M:N<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 13<br />
Achtung!<br />
Don't confuse 1:N with N:1<br />
Some notations, especially for O-O<br />
modeling, write the cardinalities differently<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 14<br />
7
Inferring Cardinalities<br />
We can construct paths between entity types<br />
These paths represent relationships<br />
composed from series of the existing<br />
relationships<br />
Their cardinalities can be inferred<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 15<br />
Fan Traps<br />
Situations where the inferred, i.e., implied,<br />
cardinality is weaker than the actual<br />
cardinality<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 16<br />
8
Participation<br />
Participation constraints: whether each entity<br />
instance must feature in some relationship<br />
instance<br />
total: yes<br />
partial: no<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 17<br />
Chasm Traps<br />
When the composed relationship, i.e., path,<br />
has a weaker participation constraint than is<br />
actual<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 18<br />
9
Weak Entity Types<br />
No key of its own attributes<br />
Must participate in a total relationship<br />
Another participant of the relationship<br />
becomes the owner<br />
Key = owner's key + partial key<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 19<br />
Summary of ER Diagram Notations<br />
Entity<br />
Weak Entity<br />
Relationship<br />
Identifying Relationship<br />
Attribute<br />
Key Attribute<br />
Multi-valued Attribute<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 20<br />
10
Summary of ER Diagram Notations<br />
…<br />
Composite Attribute<br />
Derived Attribute<br />
E1 R E2<br />
1 N<br />
E1 R E2<br />
Total Participation<br />
of E2 in R<br />
Cardinality Ratio<br />
1:N for E1:E2 In R<br />
R<br />
(min,max)<br />
E<br />
Structural Constraint (min,max)<br />
on Participation of E in R<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 21<br />
Part B: Enhanced ER Model<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 22<br />
11
¡<br />
¡<br />
¡<br />
¡<br />
¡<br />
¡<br />
Why Do We Need EER<br />
ER modeling is sufficient for representing<br />
many database schemas for “traditional”<br />
database applications.<br />
Recent applications require additional<br />
semantic data modeling concepts<br />
Class/subclass relationship<br />
Type inheritance<br />
Specialization and generalization.<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 23<br />
Subclass-Superclass<br />
Subclasses:<br />
Further refinement (grouping) of a<br />
(super)class<br />
Attributes are inherited<br />
Class/subclass relationship is different<br />
from the relationship in ER modeling.<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 24<br />
12
£<br />
¡<br />
¡<br />
¤<br />
¤<br />
¢<br />
¢<br />
¢<br />
Specialization<br />
Specialization: The process of defining a set of<br />
subclasses of an entity type<br />
Top-down conceptual refinement<br />
Allows us to<br />
Define a set of subclasses of an entity type<br />
Establish additional specific attributes with<br />
each subclass<br />
Establish additional specific relationship<br />
types between each subclass and other entity<br />
types or other subclasses.<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 25<br />
Generalization<br />
Generalization: creating a superclass by<br />
combining classes<br />
bottom-up conceptual synthesis<br />
Can be viewed as the inverse of the<br />
specialization process.<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 26<br />
13
¡<br />
¡<br />
¢<br />
¢<br />
Classification<br />
Predicate-based: when a defining predicate<br />
determines the subclass of which a given<br />
instance is member<br />
Attributed-based: when the predicate<br />
applies only on an attribute<br />
User-defined: when the user decide the<br />
subclass membership<br />
Disjoint vs. overlapping<br />
Total vs. partial<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 27<br />
Constraints on<br />
Specialization/Generalization<br />
Disjointness constraint<br />
The subclasses of the specialization must<br />
be disjoint.<br />
Specified by (d)<br />
Otherwise, the subclasses may overlap.<br />
Specified by (o)<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 28<br />
14
¡<br />
¡<br />
¡<br />
Constraints on<br />
Specialization/Generalization<br />
Completeness constraint<br />
Total Specialization<br />
Partial Specialization<br />
Disjointness and completeness constraints<br />
are independent.<br />
Superclass identified from generalization is<br />
usually total.<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 29<br />
Rules<br />
Delete from ¢ superclass<br />
subclasses<br />
delete from all<br />
Insert into predicate-based ¢ superclass<br />
insert where predicate holds<br />
Insert into total ¢ superclass insert into a<br />
subclass<br />
can't reasonably be done unless a<br />
predicate is specified<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 30<br />
15
¡<br />
¡<br />
¡<br />
¡<br />
¡<br />
¡<br />
Structure<br />
Hierarchy: single inheritance<br />
Lattice: multiple inheritance<br />
Shared subclass<br />
Attribute inheritance<br />
Single inheritance: trivial<br />
Multiple inheritance<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 31<br />
Union Types<br />
Category<br />
A subclass of the Union of some entity<br />
types<br />
A category has two or more super-classes<br />
Different from generalization.<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 32<br />
16
¢<br />
¢<br />
¡<br />
¡<br />
¡<br />
Aggregation<br />
Combining objects to form a composite object.<br />
Three types of aggregations<br />
Aggregate attribute values of an object to form<br />
the object<br />
Represent an aggregation relationship as an<br />
ordinary relationship<br />
Combine objects that are related by a<br />
relationship into a higher-level aggregate<br />
object.<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 33<br />
Association<br />
Associate objects from several independent<br />
classes.<br />
Not quite aggregation because deleting an<br />
entity instance doesn't destroy the instances<br />
it is composed of<br />
Spring 2002 <strong>CSC</strong> <strong>742</strong>: DBMS by <strong>Dr</strong>. <strong>Peng</strong> <strong>Ning</strong> 34<br />
17