0% found this document useful (0 votes)
5 views24 pages

05 DataDesign

The document outlines key rules for data design in relational databases, including mapping classes to tables and defining relationships such as one-to-one, one-to-many, and many-to-many. It also discusses generalization, structured attributes, and the use of parameters in database design. Additionally, it compares relational databases with XML, highlighting their respective advantages and disadvantages.

Uploaded by

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

05 DataDesign

The document outlines key rules for data design in relational databases, including mapping classes to tables and defining relationships such as one-to-one, one-to-many, and many-to-many. It also discusses generalization, structured attributes, and the use of parameters in database design. Additionally, it compares relational databases with XML, highlighting their respective advantages and disadvantages.

Uploaded by

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

University of Science, VNU-HCM

Faculty of Information Technology

Data Design
Assoc. Prof. TRAN Minh Triet
Department of Software Engineering

Software Analysis and Design


Using Relational Database?

2
Rule #1

 A class is mapped to a table

 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

A(MA, x, y, z) B(MB, x, y, t, u) C(MC, x, y, v)


A
+x + Simple
#y - Hard to see the relationships between entities of A, B, C
-z - Hard to process general queries

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

 A class with a structured attribute

class A A B
{
MA …
… … MA
B x; Attribute1
… Attribute2

} Structure of B:
Attribute 1
Attribute 2

 Examples?
10
Rule #7

 A class with an attribute as an array/set/bag/list

class A A B
{
MA …
… … MA
B[] x; …

}

 Examples?
11
Rule #8

 Discrete values: Create a new table for a list of


categories
 Examples?

12
Rule #9

 Parameters

Type 1

PK Param#1 Param#2 … Param#N


… … … … …

Each parameter corresponds to a column in Parameters


Parameters: only one record (row) to store the current values of parameters

?
Add a new parameter?
Disable a parameter?

13
Rule #9

 Parameters Stored as

Type 2 a string

ParamID ParamName Type Value Status


… … … … …

Each parameter is a single record (row) in Parameters


The current value of a parameter is stored as a string
Parameter values are stored as strings and the application must “interpret”
exactly the current values of parameters.

? Add a new parameter?


Disable a parameter?

14
Data as XML?

15
HTML vs XML

HTML specifies how to display/present

16
HTML

<h1> Bibliography </h1>


<p> <i> Foundations of Databases </i>
Abiteboul, Hull, Vianu
<br> Addison Wesley, 1995
<p> <i> Data on the Web </i>
Abiteoul, Buneman, Suciu
<br> Morgan Kaufmann, 1999

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>

XML specifies content


18
XML

<bibliography> Start tag


<book>
<title> Foundations… </title>
<author> Abiteboul </author>
<author> Hull </author>
<author> Vianu </author>
<publisher> Addison Wesley
</publisher>
<year> 1995 </year>
</book>
… End tag
</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

 tag: book, title, author, …


 start tag: <book>, end tag: </book>
 element: <book>…<book>,<author>…</author>
 Nested element
 Empty element : <red></red> hay <red/>
 Each XML document has a unique root element
“Well formed” document?

21
XML: Attribute

<book price = “55” currency = “USD”>


<title> Foundations of Databases </title>
<author> Abiteboul </author>

<year> 1995 </year>
</book>

22
Relational Database vs XML

23
In-class Discussion

 Relational Database  XML


 Advantages  Advantages

Discussion
 Disadvantages  Disadvantages

 Should be used in…  Should be used in…

24

You might also like