Megan Taylor

front-end dev, volunteacher, news & data junkie, bibliophile, Flyers fan, sci-fi geek and kitteh servant

Intro to Databases: UML, UML to Relations

High-Level Database Design Model
– User-friendly (graphical) specification language
– Translated into model of DBMS

Designs can be translated to relations automaticallty provided every “regular” class has a key.

UML to Relations: Classes
Every class becomes a relation; pk -> primary key

UML to Relations: Associations
Relation with key from each side

Keys for Association Relations
Depends on multiplicity
c1(k1, o1)
c2(k2, o2)
a(k1, k2) – what is the key? k2
0..1 or 1..1 on one side, then the key attribute from the other side is a key for the association

Association Relation always needed?
Depends on multiplicity
c1(k1, o1)
c2(k2, o2)
a(k1, k2)
can fold relation a into c1 or c2
1..1 on one side and * on the other, add k1 to c2
0..1 on one side and * on the other, add k1 to c2 if can have NULLs
k2 is still a key

UML to Relations: Association Classes
Add attributes to relation for association
Require a key for every “regular” class – not association class
Rules for determining keys and “folding” apply

Self-Associations
Student(sID, sName, GPA)
Sibling(sID1, sID2)
College(cName, state, enrollment)
Branch(home, satellite)

UML to Relations: Subclasses
1) Subclass relations contain superclass key + specialized attributes
2) Subclass relations contain all attributes
3) One relation containing all superclass + subclass attributes

Best translation may depend on properties

For S(K, A) S1(b) S2(C) where K is the key
1) S(K, A) S1(K, B) S2(K, C)
2) S(K, A) S1(K, A, B) S2(K, A, C)
3) S(K, A, B, C)

If heavily overlapping, design 3 is best
If disjoint, complete, design 2 is best, modify to get rid of S

UML to Relations: Composition and Aggregation
Comnposition 1..1 on the left hand side
College(cName, state) Department(dName, building)
College(cName, state) Department(dName, building, cName)

November 18, 2011 | Comments Off on Intro to Databases: UML, UML to Relations | Categories: Posts | Permalink

Comments are closed.

%d bloggers like this: