Professional Documents
Culture Documents
Relation
A relation is a named& two' two'dimensional table of data "able consists of rows (records) and col mns (attrib te or field) Re* irements for a table to * alif$ as a relation relation: : #t m st ha+e a ni* e name ,+er$ attrib te +al e m st be atomic (not m lti lti' ' +al ed& not composite) ,+er$ row m st be ni* e (can-t ha+e two rows with e.actl$ the same +al es for all their fields) Attrib tes (col mns) in tables m st ha+e ni* e names "he order of the col mns m st be irrele+ant "he order of the rows m st be irrele+ant
#s this a relation00
Employee_ID 122 Name A Department 3 Course Age %1 $rs& / 4544& months& 1% Research da$s /% $ears& : "a.& 9a+a months& %6 da$s /% $ears& : "a. months& %6 da$s
162
162
Con+ersion to Relation...
Employee Age_ o Name Department Course Age_Year Age_Days _ID nths 122 122 162 162 A A 7 7 3 3 8 8 4544 Research "a. 9a+a
Mohit Agrawal @GU
%1 %1 /% /%
/ / : :
1% 1% %6 %6
;
>e$ ?ields
>e$s are special fields that ser+e two main p rposes rposes: : Primary keys are ni* e identifiers of the relation in * estion. estion. ,.amples incl de emplo$ee n mbers& social sec rit$ n mbers& etc. etc. This is how we can guarantee that all rows are unique Relationships between relations is accomplished thro gh Foreign keys keys. . Foreign Key is an attrib te in a relation that ser+es as a primar$ @e$ of another relation >e$s can be simple (a single field) or composite (more than one field) >e$s s all$ are sed as inde.es to speed p the response to ser * eries
A Mohit Agrawal @GU
Relational 4chema
Primary Key
Foreign Key
=bCecti+es
Dhat is Relational 4chema Con+ert an ,R Diagram to Relational 4chema for f rther implementation Learn the process of <ormaliEation of a Relational 4chema
12
Integrity Constraints
R les that facilitate acc rac$ and integrit$ of data in a database
Domain Constraints ,ntit$ #ntegrit$ Referential #ntegrit$ Action Assertions F 7 siness r les les. .
11
Domain Constraints
Domain is the possible set of +al es that ma$ be assigned to an$ attrib te
Attri!ute Customer_ID Domain Name Customer_IDs Description "et o# all possi!le customer IDs "et o# all possi!le customer Names "et o# all possi!le cities
Mohit Agrawal @GU
Customer_Name
Customer_Names
City
Cities
Entity Integrity
<o 5rimar$ @e$ attrib te or its component can be <ULL Used to ens re that
,+er$ relation m st ha+e a primar$ @e$ Data +al es for that primar$ @e$ m st be +alid G arantees that e+er$ primar$ @e$ attrib te is not <ULL
1/
Referential #ntegrit$
Customer_ID 1222 1221 122% Name A 7 C Address A7C 38G 4"U City Delhi M mbai <oida "tate Delhi Maharashtra U.5 (ostal_Code 1%/6;: 1%:;6/ 11:;6/
Not (ossi!le to enter order *& *rder_ID =1 =% =/ *rder _Date April /& %21% April 6& %21% April 6& %21% Customer_ID ----------122% 12%2 <ULL
Mohit Agrawal @GU 16
Referential #ntegrit$
"ables are associated sing ?oreign >e$s Referential #ntegrit$ r le states that if there is a foreign @e$ in one relation&
either each foreign @e$ +al e m st match a primar$ @e$ +al e in another relation (Mandator$ relations)or the foreign @e$ m st be <ULL for optional relations
1;
Referential integrity constraints are drawn via arrows from dependent to parent table
1:
7 siness R les
4tatements that define or constrain some aspect of the b siness Assert b siness str ct re ControlFinfl ence b siness beha+ior ,.pressed in terms familiar to end sers A tomated thro gh D7M4 software
11
1A
Insertion!can-t enter a new emplo$ee witho t ha+ing the emplo$ee ta@e a class Deletion!if we remo+e emplo$ee 162& we lose information abo t the e.istence of a "a. Acc class odi#ication!gi+ing a salar$ increase to emplo$ee 122 forces s to pdate m ltiple records
Mohit Agrawal @GU 1B
Data Normali%ation
5rimaril$ a tool to +alidate and impro+e a logical design so that it satisfies certain constraints that avoid unnecessary
duplication of data
"he process of decomposing relations with anomalies to prod ce smaller& well well-structured relations
%2
(A+.
(art_Num!er (art_color
Aim is to con+ert an ,R diagram to its logical schema e* i+alent so that it can be implemented later
%1
4teps in Con+ersion
4",5 1 ! Map Reg lar ,ntities
Composite Attrib tes M lti'Hal ed Attrib tes
4",5 6 ! Map Associati+e ,ntities 4",5 ; ! Map Unar$ Relationships 4",5 : ! Map ternar$ Relationships
Mohit Agrawal @GU %%