05 DataDesign
05 DataDesign
Data Design
Assoc. Prof. TRAN Minh Triet
Department of Software Engineering
2
Rule #1
Examples?
3
Rule #2
One-to-one relationship A B
MA …
1 1 … MA
A B
…
A B
… MB
MB …
…
A B
AB MA MA A B
… …
MA MB
A B MB MA
… …
MB
…
MB
… Examples? 4
Rule #3
One-to-many relationship
1 *
A B A B
MA …
… MA
…
Examples?
5
Rule #4
Many-to-many relationship
* C *
A B A C B
MA MA MB
… MB …
…
Examples?
6
Rule #5
Generalization
A B C
B C Examples?
#t
-v
#u
7
Rule #5
Generalization A
A(M, Type, x, y, z, t, u, v)
A
+x + Overview of all entities of different subtypes
#y - Waste of storage
-z
Type x y z t u v
A
B C
B
#t
-v C
#u
Examples?
8
Rule #5
Generalization
Common_A
Common_A(M, x, y)
A
+x
#y
X_B X_A X_C
-z
X_B(M, t, u) X_B(M, z) X_C(M, v)
B C
#t + Efficient storage
-v + Overview of all entities
#u
- Complexity
Examples?
9
Rule #6
class A A B
{
MA …
… … MA
B x; Attribute1
… Attribute2
…
} Structure of B:
Attribute 1
Attribute 2
…
Examples?
10
Rule #7
class A A B
{
MA …
… … MA
B[] x; …
…
}
Examples?
11
Rule #8
12
Rule #9
Parameters
Type 1
?
Add a new parameter?
Disable a parameter?
13
Rule #9
Parameters Stored as
Type 2 a string
14
Data as XML?
15
HTML vs XML
16
HTML
17
XML
<bibliography>
<book>
<title> Foundations… </title>
<author> Abiteboul </author>
<author> Hull </author>
<author> Vianu </author>
<publisher> Addison Wesley </publisher>
<year> 1995 </year>
</book>
…
</bibliography>
19
XML
<bibliography>
<book>
<title> Foundations… </title>
<author> Abiteboul </author>
<author> Hull </author>
<author> Vianu </author>
<publisher> Addison Wesley
</publisher>
<year> 1995 </year>
</book>
…
</bibliography>
20
Basic Concepts on XML
21
XML: Attribute
22
Relational Database vs XML
23
In-class Discussion
Discussion
Disadvantages Disadvantages
24