Sei sulla pagina 1di 11

www.lib.ku.edu/instruction www.lib.ku.

edu/instruction

Relational Database Management System


0ollection of information organi#ed in tables
"ables are also 1relations2

Database Design

"ables are constructed and associated to each other through shared fields31common2 fields

Practical Database Design for Relational Database A set of attributes com!rises a record Records are alsoManagement 1rows2 or 1tu!les2Systems
4ields are also 1columns2 or 1attributes2

"ables are related through common fields designated as !rimary and foreign keys Allow us to find/ u!date/ and delete data 5uickly/ and hel! to ensure accuracy
$/ % $/ &' 6

Primary and Foreign Key Overview Fields


Primary ,ey A little background and terminology:
Primary key fields must be uni5ue and cannot What is a relational database contain a null +alue. What is a !rimary key 7ach table should ha+e a !rimary key field. What is a foreign key 0oncatenated keys: using more than one field as "hings to know about designing a database: a !rimary key field.

4oreign ,ey: 4ields in a table that refer "he normali#ation !rocess and how/why use it to the !rimary key in another table Relating tables
"he data this field must e8actly match data "y!es of in relationshi!s contained in the !rimary key field.
$/ % $/ &' ( 9

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

www.lib.ku.edu/instruction

What is Normalization?
"he !rocess by which we efficiently organi#e data to achie+e these goals:
7liminating redundancy 7nsuring data is stored in the correct table 7liminating need for restructuring database when data is added.

4i+e le+els of normal form


*n order to achie+e one le+el of normal form/ each !re+ious le+el must be met

Third normal orm is s! i"ient or most ty#i"al database a##li"ations$


$/ % $/ &' :

First Normal Form %&NF'


"here are no re!eating or du!licate fields. 7ach cell contains only a single +alue. 7ach record is uni5ue.
*dentified by !rimary key

$/ % $/ &'

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

www.lib.ku.edu/instruction

()am#le
item "<shirt !olo "<shirt sweatshirt colors red/ blue red/ yellow red/ blue blue/ black !rice %(.&& %(.&& %(.&& (:.&& ta8 &.;& &.;& &.;& %.(:

"able is not in first normal form because: Multi!le items in color field Du!licate records / no !rimary key
$/ % $/ &' '

()am#le
item "<shirt "<shirt !olo !olo sweatshirt sweatshirt color red blue red yellow blue black !rice %(.&& %(.&& %(.&& %(.&& (:.&& (:.&& ta8 &.;& &.;& &.;& &.;& %.(: %.(:

"able is now in first normal form.


$/ % $/ &' =

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

www.lib.ku.edu/instruction

Se"ond Normal Form %*NF'


All non<key fields de!end on all com!onents of the !rimary key.
>uaranteed when !rimary key is a single field.

$/ % $/ &'

()am#le
item "<shirt "<shirt !olo !olo sweatshirt sweatshirt color red blue red yellow blue black !rice %(.&& %(.&& %(.&& %(.&& (:.&& (:.&& ta8 &.;& &.;& &.;& &.;& %.(: %.(:

"able is not in second normal form because: #ri"e and ta) de!end on
$/ % $/ &'

item / but not "olor


%&

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

www.lib.ku.edu/instruction

()am#le
item "<shirt "<shirt !olo !olo sweatshirt sweatshirt color red blue red yellow blue black item "<shirt !olo sweatshirt !rice %(.&& %(.&& (:.&& ta8 &.;& &.;& %.(:

"ables are now in second normal form.


$/ % $/ &' %%

Third Normal Form %+NF'


?o non<key field de!ends u!on another.
All non<key fields de!end only on the !rimary key.

$/ % $/ &'

%(

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

www.lib.ku.edu/instruction

()am#le
item "<shirt "<shirt !olo !olo sweatshirt sweatshirt color red blue red yellow blue black item "<shirt !olo sweatshirt !rice %(.&& %(.&& (:.&& ta8 &.;& &.;& %.(:

"ables are not in third normal form because: ta) de!ends on


$/ % $/ &'

#ri"e / not item


%6

()am#le
item "<shirt "<shirt !olo !olo sweatshirt sweatshirt color red blue red yellow blue black !rice %(.&& (:.&& "ables are now in third normal form.
$/ % $/ &' %9

item "<shirt !olo sweatshirt ta8

!rice %(.&& %(.&& (:.&&

&.;& %.(:

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

www.lib.ku.edu/instruction

,nother ()am#le
?ame @eff Smith ?ancy @ones @ane Scott Assignment % Article Summary Article Summary Article Summary Assignment ( Poetry Analysis Reaction Pa!er Poetry Analysis

"able is not in first normal form because: Assignment field re!eating 4irst and last name in one field ?o Aguaranteed uni5ueB !rimary key field
$/ % $/ &' %:

,nother ()am#le
Assignment *D % ( 6 Descri!tion Article Summary Poetry Analysis Reaction Pa!er Assignment *D % % % Student *D % ( 6 4irst ?ame @eff ?ancy @ane .ast ?ame Smith @ones Scott ( ( 6 Student *D % ( 6 % 6 (

"ables are in third normal form.


$/ % $/ &' %;

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

www.lib.ku.edu/instruction

Relationshi#s
Relationshi!s are created between tables using the !rimary key field and a foreign key field
Cne to Cne Relationshi!
Cne record in a table relates to one record in another table

Cne to Many Relationshi!


Cne record in a table can relate to many records in another table

Many to Many Relationshi!


Many records in one table can relate to many records in another table

$/ % $/ &'

%'

Relationshi#s in First ()am#le


item "<shirt "<shirt !olo !olo sweatshirt sweatshirt color red blue red yellow blue black one to one one to many
$/ % $/ &'

item "<shirt !olo sweatshirt

!rice %(.&& %(.&& (:.&&

!rice %(.&& (:.&&

ta8 &.;& %.(:


%=

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

www.lib.ku.edu/instruction

Relationshi#s in Se"ond ()am#le


Assignment *D % ( 6 Descri!tion Article Summary Poetry Analysis Reaction Pa!er Assignment *D % % % ( ( Student *D % ( 6
$/ % $/ &'

Student *D % ( 6 % 6 (

4irst ?ame @eff ?ancy @ane

.ast ?ame Smith @ones Scott

one to one one to many many to many


%$

-ibliogra#hy
Dernande#/ Michael @. Database Design for Mere Mortals. San 4rancisco: Addison<Wesley/ %$$'. 0ha!!le/ Mike. 1 Database ?ormali#ation Easics.2 : August (&&%. Cnline. *nternet. A+ailable htt!://databases.about.com/library/weekly/aa&=&:&%a.htm Association for >eogra!hic *nformation. >*S Dictionary. %$$$. Cnline. *nternet. A+ailable htt!://www.geo.ed.ac.uk/agide8e/term =(% Wise/ Earry. 1Database ?ormali#ation and Design "echni5ues.2 % August (&&&. ; !!. Cnline. *nternet. A+ailable htt!://www.!h!builder.com/columns/barry(&&&&'6%.!h!6

$/ % $/ &'

(&

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

www.lib.ku.edu/instruction

F!rther Reading
Darrington/ @an .. Relational Database Design 0learly 78!lained. San Diego: Academic 78!ress/ %$$=. 0ha!!le/ Mike. 10hoosing a Database Product.2 ; May (&&%. Cnline. *nternet. A+ailable htt!://databases.about.com/library/weekly/aa&:&;&%a.htm >ilmore/ W.@. 1*ntroduction to Database ?ormali#ation.2 (' ?o+ember (&&&. Cnline. *nternet. A+ailable htt!://www.de+shed.com/Ser+erFSide/MySG./?ormal/?ormal %/!age%.html

$/ % $/ &'

(%

) (&&' *nstructional Ser+ices at ,- .ibraries/ "he -ni+ersity of ,ansas

Potrebbero piacerti anche