You are on page 1of 32

CHAPTER

DotoboseNormolizqtion
5.1 KEY'- W Thereis only oneprimarylceyin a table.But there
A key is that data item that exclusively identifies a keys.
canbemultiplecandidate
record. For example, Account-number,Product-code,
Employee_numberand Customer-numberare used as
key fields becausethey specifically identify a record
stored in a database. 5.1.4 CompositeKey
In many cases,aE we design a database,we will
5.1.1SuperKey have tablesthat will use more than one column as
A. Super Key for hn entity is a set of one or more part of the primary key. Theseare called Composite
attributes whose combined value uniquely identi- Keysor (concatenatedkeys).In other words, when a
fies the entity in the entity set. For example, for an record cannot be uniquely identified by a single
entity set Employees, the set of attributes field, in such casesa compositekey is used.A com-
lemp-name, address) can be considered to be a posite key is a group of fields that are combined
super kep if we assume that there are no fwo togetherto uniquely identify a record.
employees with the same emp-name as well as the
sameaddress. 5.1.5 SecondoryKey
5.1.2 Primory
Key A Secondary Key is an attribute or combination of
Theprimary key uhiquely identifies eachrecordin a attributesthat may not be a candidatekey but clas-
tablg and must never be the same for two records. sifiesthe entity set on a particular characteristic.For
For example,emp_codecan be primary key for the example, the entity set EIvIPLOYEEhaving the
entity set Employees. attribute Department,which identifies by its value
The primary key should be chosensuch that its which means all instances of EMPLOYEE who
attributes are never or very rarely changed. For belongto a given department.
mstance,the addressfield of a personshould not be More than one employeemay belong to a depart-
part of the primary key, sinceit is likely to change. ment, so the Departmentattribute is not a candidate
Emp_code,on the other hand, is not changed,till he key for the entity set EMPLOYEE,since it cannot
is working in the organization. uniquely identify an individual employee. How-
ever, the Departmentattribute does identify all
@ Theprimary kty of a relationcan be said to be a employeesbelonging to a given department. Hence,
it canbe consideredas a secondarykey.
minimalsuperkey.
5.1.6 Forgign Key
5.1.3 CondidoteKey In a relation, thg column whose data values corre-
A CandidateKey is an attribute o4 set of attributes spond to the values of a key column in anotherrela-
that uniquely identifies a record. These attributes or tion is called a ForeignKey.The supp_codekey is a
combinations of attributes are called candidate keys. ForeignKey as seenin Figure 5.1.
ln such a case, one of the candidate key is chosen to
@ ly1a relational database,theforeign key of a relation
be a primary key.The remaining candidate keys are
called Alternate keas. may bethe primary key of anotherrelation.
50 Introductionto Dotobose Monogement System!

deletion of data irr.-one relation, while forgetting


Productl
to make corresponding changes in other rela-
tions.

@ pvvillg the processof normalization,we can identify


Supplier:)
dependencies, which do causeproblemswhen delet-
ing or updating'Normalizationhelpsin simplifythe
structureof the tables.
Figure 5.1 Conceptsof foreign key
.
A fully normalized record consists of:
5.2 RELATIONSHIPS (a) A primary key that identifies that entity'
(b) A set of attributes that describe that entity'
Entities may have several relationships among In the Processof normalization, data are grouped
themselves. Whenever an attribute of one entity in the simplest possible way so that changescan be
refers to another entity, there exists a relationship
made later with minimum impact on the data struc-
between the two entities' Relationships was dis- ture. Various steps in normalization Process are
cussedin detail in Section3'2.3 of.Chapter 3'
described later in this chaPter'

5.3 WHATISNORMALIZATION? FORM(l NF)


NORMAT
5.4. FIRST
Normalizatioreis the name given to the process of A table is in the First NormalFormwhen it contains
simplifying the relationship among data elements in no repeating grouPs. The repeating columns or
a reiord. Normalization replacesa collection of data fields presentin an unnormalizedtableare removed
in a.recordstructure by another record design which from the table and put into separatetable or tables'
is simpler, more predictable and therefore more Thesetablesare dependenton the parent table from
manageable. which it is derived.The key to thesetablesmust also
The goal of a relational database design is to be a part of the parent table,so that the parent table
generate a set of relation schemes that allow us to and the derived tablescanbe relatedto eachother'
Jtore information without any redundant (repeated) Isolate repeating groups from an entity because
data. It also allow us to retrieve information easily they are easierto processseparately,from rest of the
and more efficientlY. entity. Figure 5.2 shows an unnormalized table
The first step towards Normalization is to convert structure.
E-R model intoTablesot Relations'The next step is to
examine the tables for redundancy and if necessary, groups,it is saidto be
@ tlJYsna tablehasno repeating
change them to non-redundant forms. This non- (1
infirst normalform NF). Thatis,for eachcellin a
redundant model is then converted to a database table(onerow and onecolumn),therecanbeonly
definition, which achieves the objective of the oneaalue.Thisaalueshouldbeatomicin thesense
databaseDesignPhase. thatit cannotbe decomposedintosmallerpieces'

5.3.1 Needfor Normolizotion As seenin Figure 5.2,the first four attributes(Em-


Normalization reduces redundancy. Redundancy is ployee number, Employeename, Storebranch and
the unnecessary repetition of. a field. It can cause Department)are virtually constant.The remaining
problems with storage, retrieval and updation of threeattributes(Item number, Item description,and
data. Redundancy can lead to: Sale price) contain data that change and are
(a) Inconsistencies-errors are more likely to occur repeatedwith different salesPersons.Therefore,the
when facts are repeated. repeatinggroup should be separatedfrom the eltity
"salesperson."
(b) Update anomalies-inserting, modifying and
deleting data may cause inconsistencies. Incon- The normalized file is shown in Figure 5.3.It con-
sistency occurs when we perform updation or sistsof two files:
!ll*Jbose Normolizotion Aa

Employee Item
name number
2l 130680Anand K Downtown Hardware TRIO Router
sAl Saw
PT6 Drill
A B 1 6 Lawnmover
30142101 Zadoo S Dadeland Home TTI Humidfier
appliances
D S I O Dishwasher
41984620 Balwant Cutter point Auto parts MCl6 Snow tire
AC146 Alternator
BBIOO Battery
6t2w12l Bhagwan Fashionspot Men's HSl0 Suit
clothing

Figure 5.2 Unnormalized file for sales

(b) The salespersonitem file with employee nurT',trer


.* = Key
and item number as new attributes. These tlrycr
ar/ Employee Employee attributes are added to relate the records in tliis
numEr nm€ Store brmch Departm€nt
file to the salesperson data file. The two attrib-
2l r 30680 Anmd K Downtown Hudwre
utes are used together for accessingdatar.Thr'lr,-
30t42t01 Zadoo S Dadelurd Home appliances
fore, two keys are used iogether and such a Kr:y
41984624 Balwmt Cutter point Auto ptrts
is called a concatenatedkey.
61204721 Bhagwm Fashion spot Men's clothing

SalesD€rson
Data File
5.5 FUNCTIONAT
DEPENDENCIES
Functional dependencies play an important role in
differentiating good dar:abase design from not to
2l l 30680 TRIO Router
good database design. Frunctional dependencies ere
21130680 SAI Saw
the consequence of the interrelationships amonl]
2l 130680 Pr6 Drill
21130680
attributes of an entity rcpre$ented by a relation.
AB16 Lawnmover | 245.@
30142r01 Trl Humidfier I I14.00
Alternatively, it may be due to the relationsl"rip
3014210r DSI$ between entities that are also represented by a rela-
4l tr84{i2!i I r!
!v1,.-: tion. Given a relation R, atrl..ibuteY of R is function-
+1e84620 4.C146 ally dependent on attribute X of R if and only if each
4t984620 Bg loc X-value in R is associatecl with it precisely one
6t2o.l"72l HSl0 Y-value in R.

n€ 4 functional dependenr:1 is denotedby X - + Y ,


betuteen
two setsof attributesX andY.
Figure5.3 Firstnr:rmatizeri
lils-lor s;,!es
The salesp'ersiltl
Cftt$fil.e wi:h enrFloy*e rt r il€r To understand functional d.ependenciesin a better
as the primarl' Ley. way, let us see the database containing inforrnation
concerning suppliers(S)and parts(P).The suppliers r€ f{6fg that in relation S, ute haae both S.SNo ->
and parts are uniquely identified by Supplier num-
bers(SNo)and Partno (PNo). Name and Name -+ S.SNo becauseName is an
alternatekeyfor relationS.
SNo Name Status City

S+ 51 Shyam 20 Bombay Similarly, in the Student (Name, Address, Subject,


32 Ram 10 Calcutta Grade) relation, following functional dependencies
S3 Amit 30 Calcutta should hold.
g Chirag 20 Delhi
NaIn€ -) Address
S5 Ramesh 30 Calcutti
Name Subject -+ Grade
The underlying semantics of these two functional
PNo Name Colour Weight City dependencies are that the address of a Student is
P+ P1 Nut Red t2 Bombay unique and in each subject a student gets a unique
P2 Bolt Green l/ Calcutta grade.
P3 Screw Blue 77 Goa Consider an Employee database as Employee
P4 Screw Red l4 Bombay (Emp-Code, Emp-Name, Dept, Grade, Salary, Age,
P5 Handle BIue 12 Bombay
Address) relation.
P6 Wire Red T9 Delhi
The following functional dependencieshold:
In the Supplier and parts databases,attributes
fL: Erqp_Code-+ Etll-Narn€t
Name, Statusand City of relation S are each func-
tionally dependenton attribute SNo, becausegiven (each employee has a unique Emp-Code)
a particularvalue for SNo, there existspreciselyone f2: Etg2-Code -+ DeDtt
correspondingvalue for eachof Name, Statusand (an ennployeecan work in one department only)
City. Symbolicallywe canwrite: f 3: Emp-Code Grade Age -) Salary;
S.SNo +s.Na'me (empl.oyee'ssalary depends on his age and grade)
S.SNo -tS.Status
f4: Er{)-Cod€ --> Aget
S.SNo +S.CitY
(eachr:mployee his a unique age)
The statement"S.SNo+ S.City" is read as "attribute f5: Erql-Code -+ Address;
S.Cityis functionallydependenton attributeS'SNo".
(eachemployee has unique address)
The statement"S.SNo-r S. (Name, Status,City)"
can be similarly interpret,ed if we consider the In this relation Emp-Code is not functionally
combination(Name, Statu,';,City) as compositekey dependent on Salary or Age, becausemore than one
of relations.Functionaldependencycan be shown employee can have the same salary and can be of the
diagrammatically as in Figure5,4. sanle age.

Figure 5.4 Functionaldependenciesin relationS and P


53
lotobose Normolizotion

5.5.1 FullFunctionolDePendencY In Figure 5.6, non-key attributbs Narye,Addr and


Aseari dependenton RNo, and Dateof Comp(Date
\ -+ Y is a full functional dependency, because
oi Comptetion) i.e. non-key attribute depends on
:emoval of any attribute A from X would result into
RNo (key attribute) as well as on Course(non-key
Jre cancellation of dependency. In other words, for
attribute).
:n-v attribute A e X, it does not functionally deter-
nine Y. For example, in the relation S, the attribute 5.5.3 TronsiliveDependency
CITY is functionally dependent on the composite
:ttribute (SNo, Status)' However CITY is not fully A functional dependencyX -+ Y in a relationscheme
:unctionally dependent on this composite attribute R, is a transitive dependency if there is a set of
becauseit is also functionally dependent on SNo. (If attributes Z thratis neither a candidate key nor a
\ is functionally dependent on X but not fully so, subsetkey of R and both X -> Z andZ + Y hold'
'jren X must be composite). A generalcaseof transitive dependencies is as
follows:
B Whenall non-keyattrihutesare dependent on the A,B,C are threecolumnsin a table
keyattribute,it is calledfull functionaldependency If C is relatedto B
(SeeFigure(5.5) If B is relatedto A
Then C is indirectlY relatedto A.
This is the casewhen transitive dependencyin a
table exists.We can remove transitive dependency
RNo Name Addr Age Course by splitting each relation into two separatetables,
which are to be linked using a foreign key'
Figure5.5 Concept of full dependency
functional When one non-key attribute depends on other
tn the above example non key attributes (Name, non-kev attribute, it is called a transitive dep*n-
-{ddr, Age and Course) are dependent on key dency(SeeFigure5.7(a)and Figure5.7(b)).
attribute RNo. Here RNo stands for Roll Number. To calc'ulateDistancein Figure 5.7@),which is a
non-key attribute, we must know origin and Desti'
5.5.2 PortiolDePendenc'Y nation wlhich are also non-key attributes, i.e., one
non-key attribute is dependenton one or more than
-{,functional dependencyX '-+ Y is a parnal depen-
one non-key attributes.Here, distancehas the tran-
ddncyif someattributes.Ae X can be removedfrom
dependencY.
\ and the dependency still holds' Partial sitive
dependencyin a record type occurs when some As seen in Figure 5.7(b), transitive dependency
r,or,-k"y atiribute dependson the key atttibute, and occurs becauseone non-key attribute is dependent
the remaining non-key attr:ibutesdepend on key on other non-key attribute i.e' if student is in I" year
attribute and on one or more non-key attributes' In then he has been assignedHostel Gnndhi,.if he is in
other words, all the non-key attributes are not II"d year, Hostel assignedis lawahar;III'. year the
dependenton the key attriloute.There is a partial hostbl assignedis lndrl. Thus, Hostel assignedto a
dependencyof non-key attr:ibuteseither on the key student is dependent rcn the year of study in the
atlributeoron the non-keyattribute.(SeeFigure5'6) college.

Figure 5.6 Conceptof partial dependency


I
54 lntroductionto Dotcbose MonogemeniSystems

dependents. Also note that the employee, projects


SNo OriEin Destination Distance and dependents are not directly related to one
another.
To keep the tuples in the relation consistent, we
must keep a tuple to represent every combination of '
Figure 5.7(a) Conceptof transitivedependency an employee's dependent and an employee's proj-
ect. This constraint is specified as a multivalued
RNo Name Dept Year Hostel dependency on the EMP relation. Informally,
whenever two independent 1:N relationships A:B
and A:C are mixed in the same relatiorr, then multi-
valued dependenciesmay arise.
Figure 5.7(b) Conceptof transitivedependency
Consider the Course (Course#, Teacher, Student,
Time, Room) relation as given in Figure 5.8. Con-
5.5.4 MultivoluedDependency sider an instance of multivalued dependencies
mL : Course# -+-+ Tirne, Room
Functionaldependenciesrule out certain tuples from m2 : Course# -+-+ Sfudent
being in a relation. If A -+ B, then we cannot have Course# Teacher Student Time Room
two tuples with the same A value but different B
BSO3 Jain,S Beena M33
values. Multiaalued dependencies, on the other
BSO3 Jain,S Aman M33
hand, do not rule out the existence of certain tuples, PC02 Singh,S. Bipin M52
which have multiple dependencies. Instead, they PC02 Singh,S. , Aman M52
require that other tuples of a certain form be present PC02 Singh,S. Kamal M52
in the relation. BSO3 Bose,V. Vivek Th7 1
BSO3 Bose,V. Eeena Th7 1
BS03 Bose,V. Kamal Th7 1
Multivalued dependencies are a consequence of
PC02 Arora,K. Bipin F7 1
first normal form. First normal form does not allow PC02 Arora,K. Aman F7 1
an attribute in a tuple to have more than one value. PC02 Arora.K Kamal F7 1
If we have two or more multivalued indelpendent
Figure 5.8 An instanr:eof the multivalued dependen-
attributes in the same relation schema, then we
cies in relertionCourse (Course#,Teacher,
would get into a problem of having tro rep,eatevery
Student, T'ime,Room)
value of one of the attributes with everv value of the
The meaning of these two multivalued dependen-
other attribute to keep the relation irrsiances consis-
cies are that the same te,acheris teaching a particular
tent. This constraint is specified by a multiaalued
course irrespective of time or room in which the
deryendency.
course is held. Moreover, students registered for a
W Functionaldependencies are also referredto as course are not deterrnined by the time or room
equality genercting depe.nilencies, where the course is held.
and multiaa-
Iued dependenciesare also referredto as tuple
generuting dependencies. 5.5.5 Join Dependency

For example,considerthe following relation EMP: Join dependencyis a constraint, similar to a Func-
tional Dependencyor a Multivalued Dependency. It
ENAME PNAME DNAME is satisfiedif and oruv if f irc relation concernedis the
Rajan X Ganesh join of certain nurnber i:f projectiuns.And therefore,
Ramesh Y Dinesh sucha constraintis caliecta join dependency.
Ram X Babu We now considera specialclassof join Cependen-
Arjun Y Baskar
cieswhich help to capru]redata dependencieslpres-
A tuple in this EMP r,elation repreqentsthe fact ent in a hierarchicaldata structure.Fr:r exarnplie, in
that an employer whose name is ENAME works on the N{.JRS*HOMEdal"abrse shorr.n in t'..ig*re$.9"
the project whose name is PNAME and has a data has an inherertt hiErarchis:ai ,rr:galtizaei.rrr,
it
dependentwhose narne is DNAME. An employee implies that informatiron regartiing lvardru;and
may work on severalprojectsand may have several patients currently admitlcd tn "r rvarti depenclil.iiy
l,crtoboseNormolizotion 55

The second normalization makes sure that each


non-key attribute dependson a key attributeor on a
compositekey. Non-key attributesthat do not meet
this condition are split into simpler entities. Lr
Figure 5.10, each attribute in the salespersondata
file dependson the primary key "Employe#." In the
salespersonitem file, the attribute "Sales price"
depends on, a composite key ("Employee#"and
"Item#").Note that the salesprice is firmly relatedto
the salespersonnumber and the item number of the
F-rgure5.9 Hierarchical representationof a NURS-HOME sale. Also, the athibute "Item description"tags to
database "Item#,"which is part of the cornpositekey. "Item#"
:n the Nurs-home but not the facilities present in is not related in any way to the "Employee#"field.
:ut hospital (and vice versa). Since a Nurs-home This causesseveralconcertrs.An employeetransfer
:an have multiple wards, functional dependencies would make it difficult to maintain recordsbecause
r-re not adequate to describe the data dependency the salesinformation would be dropped when the
$nong NURS-HOME and WARDS or FACILITIES. salespersonleavesthe department.This is because
h this case, Multivalued dependencies, salesinformation (Item#, Saleprice) is linked with
\URS-HOME -++ WARD or NURS-HOME +-r "Employee#"in the salespersonitem file.
IACILITIES hold. To solve such a problem, we createnew indepen-
Using, first order hierarchical decomposition dent tablesfor "Item description"and "Salesprice".
FOHD) would enable us to represent data depen- ln one file, we createthe item descriptionattribute
.jencies present in a hierarchical data structure in a with item number keys from the SalespersonItem
::ore natural way. file. The remaining attributes (Employeenumber,
The NURS-HOME database shown in Figure 5.9 Item number, and Salesprice) becomethe second
',;hen decomposed, has the following representa- tableor file. (SeeFigure 5.10)
:ons: The creation of the second table offers several
benefits.Theseare:
NURS_HOME : WARD I FACILITIES
(a) Salesitems can be added without being tagged
NURS-HOME,WARD: PATIENT
NURS-HOME, to a specificsalesperson.
WARD,PATIENT : COMPLAINTSITREAT-
MENT IDOCTOR
o) If the item changeswe need to changeonly the
item file.
Thus we can store NURS-HOME database as the (c) If a salespersonleavesthe department,it would
join of
-ossless have no direct effect on the status of the items
sold.
(NURS-HOME,FACILITY)
\-r-;RS_FACILTTY
\URS-WARD(NURS-HOME,WAR.D,PATIENT,. [€ 4 tableis.in Second.normal form (2NF) if eaery
COMPLAINTS,TREATMENT,DOCTOR) non-keycolumndepends on theentireley (notjust
relations. We can use fh, and fh, to further decom- part of it). This issuearisesonlyfor compositekeys
rose NURS-WARD relation. (withmultiplecolumns).

NORMAIFORM(2NF)
5.6 SECOND
NORMATFORM(3NF)
5.7 TH|RD
A table is in the SecondNormalForm tf all its non-key
ields are fully dependent on the whole key. This A table is sa-idto be in the Third Normal Form, if all
-xeans that each field in a table, must depend upon the non-key fields of the table are independent of all
rhe entire key. Those that do not depend upon the other non-key fields of the table.
;ombination key, are moved to another table on In Figure 5.10 we can observe that there is further
rvhosekey they depend on. Structureswhich do not room for improvement. In the salespersondata file,
contain combination keys are automatically in the the attribute "Store branch" is tagged to the primary
-cond normal form. key "Employee#" while the attribute "Department"
EC
rn+rndg6tisn
il ilt\ to DotoboseMonogementSyst
J9

16oy""* Employeename Storebranch Department

21130680 Anand K Downtown Hardware

30142101 Zadoo S Dadeland Home appliances

4r984620 Balwant Cutter point Auto parts

61204721 Bhagwan Fashionspot Men's clothing

Data File
Salesperson

/
Employee#
/
Item # Saleprice(Rs.)
r'Item # Item description

21130680 TRIO 35.00 TRIO Router

2l 130680 sAl 19.00 SAl Saw

21130680 PT6 21.00 PT6 Drill

21130680 ABI6 245.00 ABI6 Lawnmover

30t42101 TTI 1r4.00 TTI Humidfier

30r42101 DS10 262.40 DS10 Dishwasher

4t984620 MCl6 85.00 M C 1 6 Snowtire

41984620 AC146 65.00 ACl46 Alternator

41984620 BBIOO 49.50 B B l O O Battery

61204721 HSIO 215.00 HSlO Suit

Item File
Salesperson ltem File

Figure 5.10 Second normalizaiion

which is a non-key attribute is related to "Store (b) Goes.to the employee data file to look up the
branch," which is another non-key attribute. Mak- store branch to which the sales person is
ing "Store branch" a key attribute requires isolating assigned.
"Department" along with "Storebranch" and placing (c) Accumulates each galesperson'ssalesin a speci-
them in a new table as shown in Figure 5.1L. fied field in the store branch file.
Note that, after completing the third normaliza- This procedure is repeated for each salespersonin
tion, we can store branch information independent the file" Figure 5.12 illustrates the processing cycle
of the salespersonsin the branch. We can also make for salesperson21L30680.
changes in the "Department" without having to
upciate the record of the emPloyee in it. In this us 4 rcIationis in thethird normalform if it is in sec-
respect, normalization simplifies relationships and ond normslform and no non-primeattributeis
provides logical links between files without losing functionally dependent on other non-prime
information. attributes.
One inherent problem with normalization is data
rtdundancy. For store branch, the system goes
tlrrough three steps: 5.8 BCNF(BOYCE-CODD
NORMALFORM)
(a) Computes total sales for each salesperson from
the salespersonitem file. Boyce-CoddNormal Form (BCNF) was proposed as
57
lc':cose Normolizotion

2l 130680 Downtown Downtown Hardware

Dadeland Dadeland Homeappliances


30142101
41984620 Cutter point Cutterpoint Auto parts

61204721 Fashion spot Fashionspot Men's clothing

Saleprice(Rs.)

2 I 130680 35.00 Router

2l l 30680 19.00 Saw

2l 130680 21.00 Drill

2l l 30680 245.00 Lawnnover

30142101 I14.00 Humidfier

30142101 262.00 Dishwasher

4t984620 85.00 Snowtire

4r984620 6s.00 Altemator

41984620 49.50 Battery

61704721 215.00 Suit

Item File
Salesperson

Figure 5.11 Third normalization

The problem in the relation GRADE is that it had


s s:mpler form of Third Normal Form (3NF),but it is
r-uch more strict than 3NF, meaning that every two overlapping candidate keys. In the Boyce Codd
normal foim GCNF), which is stronger than the
:€lation in BCNF is also in 3NF' However, a relation
:, 3NF is not necessarilybe in BCNF' third normal form, the intention is to avoid the
Consider a relation scheme in third normal form above anomalies. This is done by ensuring that for
all non-trivial functional dependencies implied by
:it has a number of overlapping composite candi-
:ite keys. In particular consider the relation the relation, determine the functional dependencies
" that involve a candidate keYs'
;RADE (Name, Student#, Course, Grade) of
The relation GRADE of Table 5'L is not in BCNF
lable 5,1. Here the functional dependencies are -> Name and
-+
\ame Course -+ Grade, Student# Course Grade' because the dependencies Student#
Name + Student# are non-trivial and their determi-
\ame + Student#, Student# + Name)' Thus, each
nants are not suPerkeYsof GRADE'
:rudent has a unique name and a unique student
:,iunber. The relalion has two candidate keys'
NORMALFORM(4NF)
5.9 FOURTH
\ame, Course) and (Student#, Course)' Each of
rese keys is a composite key and contains a com- In order to avoid undesirable updating problem in
ron attiibute Courie' The relation scheme satisfies presence of multi-valued dependencies, Fourth
--recriterion of the third normal form relation' i'e'' irlormal Form was introduced as an extension of
-+ A in GRADE'
:or all functional dependencies X BoyceCodd normal form.
58 _ _ lntroductionto Dotobose Monogement Systems

Downtown DowntownHardware
Dadeland Dadeland Homeappliances
Cufierpoint Cutterpoint Autoparts
Fashion
spot Fashion
spot Men'sclothing

Salesperson
DataFile

Y
Employee
Y
# Item# Salepdce(Rs,)
rItem# Ihm description
2l 130680 TRIO 35.00-l TRIO Router
I
21130680 s A l re.00
I) sAl Saw
2t130680 P r 6 2r.00
| PT6 Drill
I
21130680 ABI6 245,N
) A B I 6 Lawnmover
30142101 T T I I t4.00 T't I Humidfier
30tarcl DSl0 262.N DSt0 Dishwasher
4t984620 MCl6 85.00 MCl6 Snowtire
41984620 ACl46 65.00 AC146Alternator
41984620 BBIOO 49.50 BBIOOBatlery
6lm472l HSl0 215.N HSl0 Suit
Salesperson
ltemFile ItemFile

Figure 5.12 Processingcycle

Table 5.1 The GRADE relation Fourth Normal Form eliminates casesin which the
Name Student# Course Grade composite key of a record type contains two or more
James 23714539 353 A data items that are independent, multivalued facts
Neelam 427Lrc9A 329 A of an entity.
Iames 237'14539 328 in prog The fields are independent if there are no combi-
l,lohan 38815183 456 C nations that are logically related.
i.tiip 37116259 293 B
i;-eepraf
In the example given in Figure 5.13, skill and lan-
82317293 491 C
f.}eepak 823L7293 353 in prog guages are multivalued (many different skills and
farnes 23714539 491 c many different languages), but there is no logical
ikj 11011978 353 A+ dependency between a language and a skill.
Vikas $9LA827 379 in prog To put it in Fourth Normal Form, the data mustbe
separated by creating two separate tables.
DotoboseNormolizotion 59

define stricter normal forms that take into account


@ n generalizationof theBoyceCoddnorrnalform to a additional types of dependencies and constraints.
relationuthichincludesthe multianlueddependen- The idea behind domain-key Normal Form (DKNF)
ciesis calledFourthNormalForm. is to specify the ultirnate normal form that takes into
account all possible types of dependencies and con-
straints.
5.r 0 FIFTH NORMAT FORM (sNF) The domain key normai form (DKNF) does not
exhibit insertion and deletion anomalies. However,
The Fourth Normal Form is by no means the "ulti-
unlike the other normal forms, DKNF is not defined
mate" normal form. As we saw earlier, multivalued
in terms of functional dependencp multivalued
dependencies help us understand and tackle some
dependency, or join dependency. The central
forms of repetition of information that cannot be
requirements in DKNF are the basic concepts of
understood in terms of functional dependencies.
domains, keys and general conshaints. A domain
There are types of constraints called ioin dependencies
constraint is a statement that the values of a certain
that generalize multivalued dependencies, and lead
attribute lie within some prescribed set of values.
to another normal form called project-join normal
Key constrainfsis a statement that a certain attribute
.form (PINF). The PJNF is called Fifth Normal Form. or attribute combination is a candidate key. A
There is a class of even more general constraints,
generalconstraint is expressed as a simple statement
which leads to a normal form called domain-l<eu nor-
or predicate and specifies some special requirement.
malform.
Each tuple of a relation must specify this predicate
A practical problem with the use of these general-
i.e. general constraint for it to be a valid tr"rple,
ized constraints is that they are not only hard to rea-
son with, but there is also no set of sound and us 4 relationscheme is in DKNF,if euerygeneralcon-
complete inference rules for reasoning about the
straint can be inferred from the knowledge of the
constraints. Hence, PfNF and dornain key normal
attrihutesinaolaedin thescheme, their underlying
form are used verv rarelv.
domains,and the setsof attributesthat form the
Emplovee skirl Language lcevs.
An insertion anomaly in the caseof DKNF occurs
when a tuple is insertedin a relation and the result-
ing relation violatesone or more generalconstraints.
Similarly, a deletion anomaly occurswhen a tuple
mustbe separatedas from a relation is deletedand the remainingrelation
violates one or more generalconstraints.We show
Employee skitl Employee Language
these dependenciesand general constraintsin the
followingexample.
Exomple I
Consider the relation schemeTRANSCRIPT(SNo,
Figure 5.13 Fourth Normal Form
Course,Grade).Suppose the attributesSNoand Course
are numeric, 8 and 3 digits long, respectively.The
!g Theconceptof Project-join-Normal
form GINF) is attribute Gradeis a letter gradeand could be A, B, C,
an extensionof the Fourth Normalform definition D, P, F. The generalconstraintis that f.orCourses000
whenjoin dependenciesarealsoconsidered. through 90Othe Gradecan only be A,B, C,D, F. The
domain constraintsfor this relation are the follow-
ing:
5"I I DOMAIN-KEY
NORMALFORM SNois required to be 8 digits long, Courseis 3 digit
The process of normalization and the process of dis- long, and Gradehasto be from the set {A,B,C,D,P,F}.
covering undesirable dependencies was carried The key constraintfor the relation is that no two
through Fifth Normal Form (sNF) as a meaningful tuples cin exist with the same values for the key
design activity. However, it has been possible to attributes, which are SNo and Course.Obviously,
60 Introductionto DotoboseMonogementSystems

SNoCourse + Grade. applications. They select such a schemathat has


Finally, the general constraint can be expressedby redundant information that means it is not normal-
the following: ized.
if Grade > 900 then Crade e {P, F} For example, suppose that the name of an account
holder has to be displayed along with the account
else Grade e {A, B, C, D, F}
number and cash balance,every time the account is
accessed.In our normalized schema,this requires a
W The DKNF is consideredto be the highestform of join of accountwith depositor.One alternative is to
normnlization, since all insertion and deletion create a relation containing all the attributes of
anomaliesare eliminatedand all generalconstraints account and depositor.This makes displaying the
canbeaerifiedby using only thedomainconstraints account information faster. Holvever, the balance
and keqconstraints. information for an account is repeated for every
person who owns the account, and all copies must
The problem with this relation is that a tuple such be updated by the application, whenever the
as (1.2345678,991, A), which satisfiesall the domain accountbalance is updated. This processof taking a
constraints and key constraints, can be inserted in normalized schema and making it non-normalized
the relation TRANSCRIPT of Table 5.2. However, is called denormalization.Designers of databaseuse it
since the tuple does not satisfy the general con- to tune performance of systems that require time-
straint, the relation TRANSCRIPT becomes illegal critical operations.
after ihe insertion. A better alternative is to use views. A materialized
Table5.2 TheTRANSCRIPT
relation view is a view whose result is stored in the database,
Course
and reflected in the data when the relations used in
Grade
the view are updated. Like denormalization, using
2371.4539 J3J materialized view does have soace and time over-
42717390 329
heads, but it has the advantage that keeping the
23714539 928 P
38815183 456 r
view up-to-date is the job of databasesystem, not
371.1.6259 B the application programmer.
8231.7293 491 L
82317293 953 F 5.I3 CASESTUDY
I
2371.4539 491 C
1l0rt978 353 A Normalize the following data of CUSTOMER table
83910827 J / > P to 2NF using appropriate relation. Give brief expla-
nation for each level.
Exomple2 XYZLTD.
The TRANSCRIPT relation discussed above can be Cust_no : 001
Cust_name : Dev and Co. LTD.
decomposedinto the following relations:
Addr : DWARKA Sec.7. Pl. no.2
TRANSCRIPT_REGULAR (SNo, Course, Grade) Order_no : 2240
with the domain constraints (SNo being 8 digit, Order-date :5/1.1./02
Coursebeing 3 digit in the range 000 through 900, Deli_date : 1.5/ll/02
and Grade in the set {A, B, C, D, F}). The key as
before is SNo Course. Item*no Desc Rate Qty
TRANSCRIPT_SPECIAL (SNo, Course,Grade)with 001 Floppydisk(3 1/a") t70 5
024 Printer(Inkjet) 5500 2
the domain constraints (SNo being 8 digit, Course UJJ cD 450 5
being 3 digit in the range 000 through 999, and 039 Keyboard 1000 3
Grade in the set {P, F}). The key as before is SNo
Course. Solution
Step1
5.12 DENORMATIZATION Firstly, we have to write down the data in the
In some exceptional cases,database designers use unnormalized form. Without normalization, the
the redundancy to improve performance for specific data appearsas follows:
61
l':-obose Normolizotion

n-nnormalized Data: In the 2NF the element depending. upon the whole
-;;t-no key and partial key are separated and formed into
new data structure'
l;,:i_name 2
:.: jr
]:.l.er_no *Cust-no *I{em no Ddsc Rate
Qty
]:er-date
le-i_date
-:t::-.-no
2

."i*" *t*,."10*
-<:!

i;:e
2
Step2 *Order-no Order-date Deli-date
.."[*;rder-no
l:.e First Normal Form (1NF) is any data structure
-^,:irout repeating groups. So to achieve First
2
5.I4 CASESTUDY
\:':mal Form, remove all repeating grouPs. In this
:uinple, Item-no, Desc,Rate,Qty etc. repeats with Normalize the following data of personal employees
=:ch customer. table to 3NF using appropriate relations' Note that
*'
lhe primary key from the original structure is to be key fields are denoted bY
:r,-rrght into repeating grouP structure' Also the key Unnormalized Data
::e-l from the new structure (repeating group) is to
PersonalEmPloYeeTable
:e found out. The new structure is named with
* Emp-code EmPloYeecode
::rropriate name.
L Dept-code DePartmentcode
I
Mgr-code Manager code
IL
*Itbm-no Course-code Coursecode
tust-no Desc RateQtY
1 Course-title Coursetitle

= Solution
5l:st-no Cust-nameAddr Order-noOrder-datJDe[-date
Step 1
the first stage of normalization is to remove all
@ Notethat* denotes
keyfieldfor an entity.
repeating groups. So there are two tables;employee
table and training table, with the key field
-:r the first file structure Cust-no is the main key or Emp-code appearing in each.
i^,e primary key and ltem-no is the partial or
First Normal Form (1NF)
=e.-ondarykey.
Step3 Employeetable Trainingtable
* Emp-code *EmP-code
li.e Second Normal Form (2NF) is a data structure *Course-code
Dept-code
-: n'hich all non-key data elements are fully func-
Mgr-code Course-title
:rnally dependent on the primary key' If a relation
*. 1NF then we can go for its 2NF. In the 2NF we Step 2
.ook for Functional Dependence. For exarrtpLe,Desc In Second Normal Form (2NF) we have to remove
:: item is dependent on ltem-no, Rate is dependent partial key dependencies. This is done by examining
:n ltem_no. lhore tecotds possessinga compound key (i.e. a key
Similarly, Cust-name is dependent on Cusf-no, cus- comprising more than one item) and checking to see
:Jmer Addr is dependent on Cust-name and so on' whether each data field in the record relates to the
'-\-e whole key. If the field relates to only part of the key,
group such functionally dependent attributes
:nd achieve 2NF. it is removed with its key to form another table. In
62 introductionto Dqtobose Monogement Systems

the above example Course title relates only to 3. The relation is said to be in when every
Course_code, so it is removed ' with its key to form non-key attribute is fully functionally dependent
another table as Course table. on the primary key.
Second Normal form (2NF) 4. -is stricker than 3NF.
5. Every relation in BCNF is also in -.
Employeetable Training table Coursetable
*Emp-code *Emp-code *Course-code 6. \A/henall non-key attributes are dependent on the
Dept-code *Course-code Course-title kev attribute. it is called dependencv.
Mgr_code
7. A functional dependency is denoted by
between two sets of attributes x and y.
Step 3 8. When one non-key attribute depends on other
non-key attribute, it is called a - depen-
in Third Normal Form (3NF) involves examining
each record to see whether any items are mutually dency.
dependent. In this example, Dept_code and Mgr
Answer
-code are mutually dependent because the manager
of each department will always be the same. Thus 1. Normalization 2. 1NF 3. 2NF
new table department is being created for depart- 4. BCNF 5. 3NF 6. Full
ments, the key being Dept-code. Now data is com- functional
pletely norrnalized. 7. x-+y 8. Transitive
Third Normal Forrn (3NF)
EXERCISE
Employeetable Training table
*Emp-code *Emp-code Note: Answer all questions.
Dept-code *Course-code
1. Define Normalization and why is it done?
2. Explain Third Normal Form (3NF) with an
Department table Course table
*Dept-code *Course-code example.
Mgr-code Course-title 3. With the help of an example, what do you
understand by Boyce Codd Normal Form.
How does it differ from Third Normal Form.
REVIEW
OUESTIONS
WITHANSWERS 4. Write short note on:
(a) Denormalization
Fillintheblonks (b) Fourth Normal Form.
1.-- is the processof grouping the data (c) TransitiveDependency
item elernentsin the tuple representingentities (d) MultivaluedDependencies
and their relationships. 5. Explain Partial Dependency with an example.
2. When a table has no repeating groups, it is said to 6. What is join dependencies? Explain with an
be in example.
)otobase Normqlizotion 63

:
T(FST PAPERJ,B

Inlroduclionto DotaboseMoncgementSyslems

PARTI (OBJECTIVE to be answereain fi Minutes)


QUESTIONS
l. Multiplechoice 1.8 Every Boyce-Coddnormal form (BCNF)is in
a. tr NF c.3NF
1.1 The level of data abstraction which describes d. None of the above
b.2NF
how the data is actually stored is
1.9 Which normal form is most desirable?
a. Physical level c. Storagelevel
a. Domain key normal c."Third normal form
b. Conceptual level d. View level
form (DKNF) (3 NF)
1.2 An associationof several entities in an Entitl' Fourth normal form
b. Bovce-Codd normal d.
Relation model is called
form (BCNF) (4 NF)
a. Tuple c. Relationship
1.10 Complex entities can be constructedusing the
b. Record d. Field
following operation:
1.3 The overall logical structure of a database can c. Aggregation
a. SUM
be expressed graphically by
b. Union d. Collection
a. Data flow chart c. Directed graPh
1.11Which key provide the basic tuple-level
b. Flow chart d. Entity-relationship
addressin mechanismin a relationalsystem?
diagram
a. Candidatekeys c. PrimarYkeYs
L . 4 The overall design of a database is called d. None of these
b. Alternative keys
a. Schemaof the c. Structureof the primary keys of the relatedentity
1.12 The union of
database database of the relation.
setsbecomesa
b. The screenof d. View of the database
a. Superkey c. ForeignkeY
database d. PrimarykeY
b. Candidatekey
1.5 The number of entities to which another entity
1.13 A relation in third normal form is
can be associated via a relationship set is
a. in first normal form c. From transitive
expressedas dependencies
also
a. Entity c. Scheme
b. Secondnormal d. All of the above
b. Cardinality d. Attributes
form also
7.6 One limitation of the entitv-relation model is
1.14 Which one is not true?
that it cannot
a. A relation is in BCNF if it is in 4NF
a. usegeneralization c. usesingleprimary
b. BCNF is stricter than 3NF
key
c. A relation is in BCNF if ever determinant of
b. expressrelationship d. none of the above
the relation is a candidate key.
amongrelation-
ci. All are tr"ue.
ships
1..'15lf every non-key attribute is functionally
1.7 6very weak entity set can be converted to a
ciependent on the primary key, then the rela-
sirong entity set by
ticn will bq:in
a. $i:nply adding e. Using aggre6ation
a" lNF c" 3NF
appropriate
b. ?l,,lF d. .{itF
attribule
' . ' i t n g " l - ' cr r t i ; . y 3-36 A stitrrir keri is ;r s+l cf tln.e *F illtjre ftttributes
b. Usi.iig r
lirart{a.L"etclii*i:tl"rely, aili-:iv L;';
generalization set si",;eralti;.q:s
!l

a. To identify uniquely an entity in the entity 3.4 Virtual tables d. Primary key
set values
b. To make the key most powerful for faster 3.5 Weak entity set e. User views
retrieval
3.6 Fourth normal form f. Inheritance
c. To increaseeffectivenessof databaseaccess
d. None of the above 3.7 Referential g. Domain calculus
1.17 A table is in 2NF if it is in 1NF and if constraints
a. No column that is not a part of the primary 3.8 QBE h. SUM
key is dependent on only a portion of the 3.9 Update anomaly i. Foreignkey
alternatekey 3.10 Union rule j. First normal form
b. No column that is not a part of the primary k. Secondnormal
key is dependent on only a portion of the form
primary key l. QUEL
c. No column that is not a part of the primary
key is dependent on only a portion of the 4. Fillin the blonksout of the foilowing:
foreign key a. aggregation b. primary key c. Relational
d. None of the above d. attributes e. record f. schema
replication
2. SeleclTRUE or FATSE
in the foflowing g. root h. foreign key i. Normaliza-
slotemenls tion
2,1 A weak entify set has a primary key. j. BCNF k. subschema L data
2,2 Every weak entity set can be converted into a dictionary
4.1 A view of the database that appears to an
strong entity set by adding appropriate attrib-
utes. application program is known as
2.3 A candidate key can be a subset of a super key, 4.2 If relation is in _, it is in 3 NF also.
2.4 Many-to-many relationship between two enti- 4.3 _ represents relationship between the
ties can be representedby two DBTG sets. tables.
2.5 In a relational database, the foreign key of a 4.4 -is the name given to the process
relation would be the primary key of an of simplifying the relationship among data ele-
another relation. ments in a record.
2.6 Boyce-Codd Normal Form is also in Third nor- 4.5 Complex entities can be constructed using the
mal form. operation.
2,7 The subschema must contain all the descrip- 4.5 In a relational data model the columns of a
tion of certain data that are in the scheme. table are called
2.8 Codd gave 12 rules for any RDBMS to be 4.7 In a hierarchical database,modeling of many-
acceptedas a full fledged RDBMS. to:many relations is achieved by --.
2.9 Aggregation operation is used to construct 4.8 h a hierarchical database,a hashing function is
complex entities. used to locate
2.10 An E-R model uses doubly outlined rectangle 4.9 E-R model is used to describe
to represent weak entity set. model.
4.10 .--- containsthe structureof the data-
3. Motchwords/phroses
in the two columns base.
3.1 Specialization a. Functional depen-
dency
3.2 Aggregation function b. Multivalued
PARTil (DESCR|PT|VH QUESTTONS
dependency to be answeredin 2 Hours)
3.3 Entity integrity c. Doubly outlined Q. 1 What do you mean bv integrity and Referential
box Integrity? Explain with example.
Jotcbose Normolizotion 65

Q. 2 Differentiate between File processingapproach KeytoTEST PAPER 5


and Databaseprocessingapproach. L. 1.1(a) 1.2(c) 1.3(d) i.a (a) 1.5(b) 1.6(b)
Q.3 Define normalization. Why normalization is 1..7(a\ 1.s(c) 1.e(a) 1.10(c) 1.11(a) 1,.12
carried out? (a) 1.13(d) 1.14(d) 1.1s(b) 1.16(a) 1.r7(b)
Q. a Who is DBA? Explain the role of DBA in an c 2.1(F) 2.2(r) 2.3(r) 2.4(r) 2.5(r) 2.6(r)
organization. 2.10(r)
2.7(F) 2.8(r) 29 (r)
3. 3.r (f) 3.a(e) 3.5(c) 3.6(b)
3.2(h) 3.3(d)
3.7(i) 3.10(a)
3.8(g) 3.e(j)
4. 4.1(k) 4.2(j) 4.3(h) a.a(i) a.5(a) 4.6(d)
a.7@) a.8(g) a.eG) 4.10(l)

ANSWERSTO (DESCRIPTIVE
QUESTIONS)
Ans.1 Entitylntegrity:
if an attribute of a table is prime attribute (unique identifier), it can not acceptnull values, i.e.,
no component of a primary key values may be null.
Referenliollntegrity:
will also
To ensurethat J valuewhich appearsin onerelationfor a givensetof attributes
appear for certain set of attribuies in another relation. This condition is called as referential
integrity,
Ans.2 File ProcessingApproach Database ProcessingApproach

(a) Redundancy in defining and storing data In the database approach a single reposi-
which results in wastage of storagespace. tory of data is maintained that is defined
once and then can be accessedby many
users.
(b) Data definition is typically part of the DBMS software can access diverse data-
application programs themselves and basesby extracting the databasedefinition
hence file-processing software can access from the system catalog and then using
only specific database files. this definition.
(c) The structure of data files is embedded in DBMS access-programs are written inde-
the accessprogralns, so any changes to the pendent of any specific files. The structure
structure of a file may require changing all of data-files is stored in DBMS catalog
programs that accessthis file. separately from the access-program.This
property is known as program data inde-
pendence.
(d) Does not support multiple views of same Supports the multiple view of same data.
data.
(e) Data for rnuitiple application may not be A multi-user DBMS allows multiple users
integrated and is maintained in individual to accessthe database at the same time. So
files. the data for multiple operations is inte-
grated and maintained in a single central
database.
06 Introductionto Dotobos

Ans.3 Normalization is a Processof simplifying the DBA has following role to PlaY:
relationships between data elements in a (a) Administering the primary source, data-
record. base and the secondary source, of DBMS
Normalization is carried out for the follow- is the responsibility of the database
ing four reasons: administrator (DBA).
(a) To structure the data between tables so (b) Designs the database security system to
that data maintenanceis simplified' guard against unauthorized use by allo-
(b) To permit simple retrieval of data in cating password to each user.
responsequery and report requests' (c) Co-ordinates working of individuals
(c) To simplify the maintenance of data making file modifications, policy
through updates, insertion and dele- changesand improvements to database.
tions. (d) He protects databases from physical
(d) To reduce the need to restructure or re- harm by supervising the creation of
organise data when new application backup copies and establishingfall back
requirements arise' procedures.
Ans.4 The person who is responsible for the oPeral (e) Acts as a file designer and databasecon-
tion and maintenance of DBMS is called sultant to other users in the organiza-
Databaseadministrator. tion.
lt
,4ft'nAPrER
6

Relotioncll
Algebrosnd
RelotionqlCslculus
6.I RELATIONAL
ALGEBRA amount is say more than Rs 7000/- by writing the
ic:::ronal algebrausesa procedural query language foilowing:
n*:-;h is a collection of operations to rrtanipulate oBalar,.e,
7ggg(Deposit)
-:lJrurRS.It consists of a set
of such operations that In general, H'e allow cornparisonsusing relational
:i-q<inc or more relations as input and produce a operators (.=, *, 1, 1, ), ) ) in a selection predicate.
-E1\-:elation as their result.
Futhermore, we can comhine severalpredicatesintcr
a larger predicate by using the logical connectioir
6.2 RELATIONAL ATGEBRAIC OPERATIONSnamely AND (a), OR (v) and NOT (.-) operators.
ic-::ional algebraic operations can be divided into Consider another example. Suppose we r,vant
::";-; set-oriented operatiofis like union, difference, tuples which contain the faculty name "Pooja"who
Lr:=:>ection, cartesian product and relational- teachesRDBMS, from relation (tabie) Teach,then we
:r.=:.ted operatir:ns like join, selection, projection, may write the query as follows:
:-' :sion etc. We shall understand various opera-
-- ..--.of relational algebra o N"me = ,,pooja,,r
Courss= "RpgNag,'(Teach)
one by one.

5.2.1Select(o) [9 6 Gigma)is theselection


operation
symbolandn is
l-r select operation extracts specific tuples from a
-::::or1. We can use ihe lower Iogicaloperator
AND.
Greek letter sigma (o.)
- :enote selection.

ff? )ne canconsider the Selectoperntionto bea filter 5.2.2 Proiect(n)


:)tatkeeps
only thosetuplesthatsatisfila qualfuing The project operation is a unary operation which
.ondition. extracts attributes (columns) from a relation, If we
are interested in only certain specific attriirrrtesof a
:ippose you want to see tuples which have
relation, we use the project operation to project the
i:::ch_nams = "]anak puri" from Deposit table. In
relation over these attributes only. Projection is
+-,:r case,we can specify this condition with a select
denoted by Greek letter pi (n).
"rtration.
l: -::ch-name = "JanakPr.rri"(Deposit) M The Selectoperationselectsspecificrous from n
lhe conditions are specified as mentioned below: tablewhilediscardingotherraws.TheFrojectoper-
)eposit (Branch_name,Account_number, ation,on the otherhand,selectscertaincolunrns
Customer_name,Balance) from thetableanddiscards theothercolumns.
^:rgeneralselectoperations is denoted by Suppose we want to know the Customer names
I, -,ection_Con61iior.,r(<relation
name>) and their bank balance amounts from Deposit rela-
-",.'here tion, then we may write the query:
the symbol o (sigma) is used to denote the
E-eci operator, and the selection condition is a fi custorner_name,Balance(Deposit)
:,-.,-'leanexpression specified on the atiributes of The general forrn of the project operation is:
'=--rtion.
-'\'e
can also fir-rd ttrples in which the balance fi <attribute tirtt (R)
68 Introductionto Dotobose Monogement Systems

where n (pi) is the symbol used to represent the


[9 Nofe that the common memberswill appear only
project operation and <attribute lisD is a list of
attributes of relation. once,when we useunion (v) operation.
Let us take another example. Suppose we want to
print the names and addresses of those faculfy
SetDiflercnce
mernbers who are teaching "RDBMS" course then
we can write the following query: The set-difference operation, denoted by X - Y
allows us to find tuples that are in one relation but
TEName,Address(oCourse =,.RDBMS"$each))
are not in another relation
6.2.3 SelOperotions Exomple 2
There are four other relational algebraic operations. To select all those employeeswho are exclusively
Theseare; working on projectJ1.,we write X - Y, where X and
(a) set-union Y are relationsgiven in Example1 above.The result
(b) set-intersection of differenceis given as follows:
(c) set-difference X-Y:
(d) cartesian (cross) product.
-No _name
Set Unlon 103 Ritu
The result of union operation is denoted by the 104 Setu
106 Leela
symbol u. For example,X v Y (where X and Y are
two compatible relations) which is a relation that
includesall tuples that are either in X or in Y or in
!9 11e1sthat all membersof relationX are written
both X and Y. Duplicate tupleswould be eliminated,
by using set union. exceptthecommonmember.
Exomple I
X and Y are two relations,with X holding the details Sel lntersection
of employeesworking on ProjectJ1.and Y holding The result of Intersection operation denoted by
the details of thosewho are working on ProjectJ2. X n Y is an operation that includes all tuples that are
The two tablesare as under: in both X and Y.
X:
Exomple 3
-No Emp-name
To select those employees who are exclusively
101 Rita
103 Ritu working on both projectsJ1and J2i.e. thosewho are
104 Setu corunon to ]1 and 12,from Example1 we write X n
106 Leela Y. The result of intersectionis hs follows:
107 Neena
To selectall those employeeswho are: XnY:
either in ProjectJ1 or in ]2 or in both projectsJl and
J2,we write X v Y. The result of union operationis Emp-No Emp_name
given below: 101 Rita
XUY: 707 Neena

Emp-No Emp_name
101 Rita IEF lr/efg that there are only two emplayeeswho are
103 Ritu
104 Setu
workingon projectI'1,andalsoonproject12.
105 Isha
106 Leela
'1,07 CrossProduct(Caileslon Product)
Neena
l'1,2 Seema Crossor Cartesianproductis denotedby X x Y and
ks-onol Algebroond RelotionolColculus 6S

rEf-;::LSa relation on tuples whose schema contains Exomple 5


dl[ reids of X (in the same order they appear in X)
Using the relations mentioned below, supposewe
dLlnr.ed by all fields of Y (in the same order as they
want to retrieve the namesof thoseemployeeswho
rArear in Y).
work in department10,then we will usethe follow-
The result of X x Y contains one tuple (r,s) (the
ing query.
snr=.tenation of tuples r and s) for each pair of
Employee: Department:
muqi* rvhere r belongs to s (r e s) and s belongs to s
!=:r. Emp-No Emp-Name Project -No
1 Rita AX10 1 10
frqtple 4 2 Reetu AX10 20
two relationsX and Y are given as follows:
*un"-;ose 3 Seema AX1L 10
4 Leela AX10 4 30
(
Ernp_No Emp_name -rumd Emp,ortt
n (Emptoyu.Emp
o;r_rlepartment)

EquiJoin
Whentwo tablesarejoinedtogetherusingequality
106 Leela of valuesin oneor morecolumns,theymakeanEqui
707 Neena ioin.
lhe operation X x Y gives the resulting combina- B ln equijoin, thecomparisonoperator= is only used.
r.crs as follows: Theresult of an equijoin will alwayshapeoneor
morepairsof attributesthat haaeidenticalaaluesin
eaerytuple.
Emp_No Emp_name Project
101 Rita AXlO
101 Rita AX11 Theto(o).loin
103 Ritu AXlO A generaljoin condition is of the form:
103 Ritu AX11 <Condition>AND <Condition>AND....AND
104 Setu AXlO <Condition>
104 Setu AX11 where eachCondition is of the form A; 0 8,, Here,
106 Leela AXlO A, is an attribute of relation X. B' is an attribute of
106 Leela AX11 relation Y. Here A; and B, have ihe same domain.
107 Neena AXlO The greek letter 0 (theta) is one of the comparison
107 Neena AX11 operators(=, 1, 3, ), 2, *). A join operationwith such
a general join condition is called a Thetaioin. By
theta join, tupXeswhose join attributes are null do
@ Notethat abouecommands will giaeall combina- not appearin the result.
tions of employe,es working on projectAX1.0and
alsoonproject4XL1. Natural Join
Lr the nafural join also, the comparisonoperatoris
always the equality operator =, but only the equi
6,2.4 DifferenlTypesof Joins join contains two identical columns from the rela-
lte join operator (><), allows to combine two rela- tion being joined. It is of coursealways possibleto
::ns to form a single new relation. The tuples from eliminate one of those two columns via the Proiect
:.€ operand relations that participate in the operation(n). ,An equi join with one of the two iden-
;,:eration and contribute to the result are related. tical columns eliminated is called a natural join.
lle join operation allows the processing of relation- Thus, natural join will also give a new table that
;,r-rpsexisting between the operand relations. doesnot have any duplicate columns.
r, r n
to Dotobose Monogemenf Systems
IntrorCuciion

QuterJoin 6.4"2 Conditions


* *
An outer join is a type nf equi join that is used to Conditions of the form x y, where is any one of
show all data from one table, even if corresponding relation operators =, 1), 1, 1=, ), )=, and at least
data is not found in a second table. Outer joins are one of x and y is an expression of the form T'A and
n:ost commonly" used with tables having one-to- the other is either a similar expression or a constant' i
many relationships.
6"4.3 Well-formedfotmulos (WFFs)
6.3 RELATNONALCALCULUS The WFFSs should be those sequences of symbols
In reiational calculus, a query is expressed as a that are unambiguous and make sense.This can be
formula consisting r:f a number of variables and an ensured by stating some rules for the construction of
expression involving these variables. The formula WFFs.
describesthe properties of the result and relation to A WFF is constructed from conditions, Boolean
be tlbtained. There is no mechanism to specify how operators (AND, O& NOT), and quantifiers (3,V)
thc formula should be evaluated. It is up to the according to rules F1-F5mentioned below:
ifBMS to transforrn- such non-procedural queries F1. EverI condition is a WFF.
into equivalent, efficient procedural queries. Tuple F2. If.f is a WFF, then so are (fl and NOT (/).
and domain calculus are collectively referred to as F3, If f and g are WFFs, then so are (/AND g)
rthti.annlcnlcuhrs. and (/ORg).
F4. It f is a WFF in which T occursas a free
W 7n relationnltuple calcultts,the unrinblesrepresent variablethen lT (fl and VT (fl areWFFs.
the tuples from specifiedrelations; in relational F5. Nothing elseis a WFF.
domain calulus, the aariables represent ualues
drawnfrom specifieddomnins. W Thetuplerelationalcalculusis based a
onspecifiling
numberof tuple aariables.Each tuple unriable
rangesoaera particulardatnbase relation,meaning
CALCUTUS
RELATIONAL
6.4 TUPLE thattheaariablemaytake. as itsaalueanyindiaidual
The primary construct of the tuple-oriented rela- tuplefrom thatrelation.
tional calculus (tuple calculus for short) is the tuple A simple tuple relation calculus query is of the
caluilus expression.A tuple calculus expression is form:
essentiallya non-procedural definition of sorne rela- {r lcolrD(r) i
tion in terms of some given set of relations. Such an
expressioncan be ciearly used to define the result of where t is a tuple aariablgand como( t ) is a condi-
a query/ r"rrthe target of an update, or a view, etc' tionalexpressioninvolving t.
The expression of the tuple calculus are con- The result of such a query is the set of all tuple t
structed frorn the following elements: that specifyCollD(t).
(a) Tuple v;rriahlcs
Exomple 6
fu) Conditions
(c) Well-formed formulas (WFFs) Consider the following relations:
EMPIJOYEE (Errl>-Code, EnEr-Name, Desig,
6.4.1 Tuplevoriobles Mgr-No' Doj, Salary' Conrn,
The variables in relational calculus are like variables oept_Code)
rn programming languages in that they are DEPARTMEIII (Dept Code' D€Pt-Nane,
restrictedby their types T, U, V....... Each tuple vari- Location)
eble is constrained to range over some named rela-
To find all employees whose salary is above
tion. If tuple variatrle T represents tuple f (at some
Rs. 5500, we can write the following construct of the
given tirne), then the expression T.A represents the
tuple relational calculus:
compollent A of f (at that time), where A is an
attribute of the relation over which T ranges. (TIEMPLOYEE(t) and t.sA.r.aRY > 5500)
kctiollol Algebroond RelotionolCclculus 71

he condition supr,oyEE(t) specifies that the such tuple. The conditions Erffrl-oyee(r) and
$nges relation of table variable f is employee. Each DeBartment (d) indicate tire range relations for t,
l'*'-:loyee tuple f that specifies the condition and d. The condition:
: " -:-tri,ARY
> 5500 will be retrieved. d.Dept_Nam€ ='rReEearch"

lhe above query retrieves all attributes values for is a selection condition and corresponds to a
*:::r selected EMPLOYEE tuple f. To retrieve only SELECT operation in the relationai aigebra. The
';ne of the attributes, we write: condition:
{r.Ertl)_Nams, I"SAIJARY I EMPLOYEE(L) and, d.Dept_Code = t.Dept_-Code
T . SAIJARY > 55OO }
is a join condition and serves a similar purpose to
- r-LlS construct is equivalent to following SQL the join operation.

.q.E.ECT T.ErF_rram€,
W Theonlyfree tupleuarinbles in n relational
calculus
T. sala4/
rROM EMPIJOYEE T expression shouldbe thosethat appenrto theleft of
XEERE T.SAXTARY > 55OO t h e b a(rl ) .
Erample7
lle tuple relational calculus query to retrieve the 6"4.5 SofeExpressions
;:e of joining and designation of the employee Whenever we use universal quantifier (V), existen-
-r{rosename is "RAJ" is given by:
tial quantifier (!) or negation (-) of predicatesin a
ir.Doj, r.Desig I wnlorrE(t) and calculus expression, we must make sure that the
t.ErD_Nane E trPlJ'n) resulting expressionassuressorneresults"
ln fuple relational calculus, we first specify the A safe expression in a relational calculus is one
:riuested attributes for each selected tupie f. Then that is guaranteed to yield a finite number of tuples
,,.e specify the condition for selecting a tuple fol- as its resulf otherwise the expression is called
,:if ing the bar ( | ) - namely that t be a tuple of the unsafe.
:\iPLOYEE relation. For exarnple,the expression:
{t lnot (EMPT.OYEE (t) ) }
6.4.4 Formuloin TupleRelafionolColculus is unsafe becauseit yields all tuples in a universe
i tormula (condition) is made up of one or more that are not EMPLOYEE tupies, which are numer-
;:--'rrsconnected via logical operators (and,'or and ous.
----:tanddefined recursively as follows: We can define safe expressionsmore precisely by
: Every atom is a formula. introducing the concept of the domain of a tuple
:' If Fr and F, are formulas, then so are (F, and Fr), relational calculus expression.
(F, or Fr),not (F) andnot (F).
GF Domain is the set of aII aaluesthat eitherappearas
ln addition, two special symbols called quantifiers
::n also appear in formulas; these are the universal constantaaluesin the expressionor exist in any
:'.rnatifier(V) and the existential quantifier (3). tableof the relationsreferencedin the expression.

Suer'esUsingthe Existentiol
Quqntifier The domain of {t lnot (EMPLOYEE(I))}is the set of
j rt/e want to retrieve the Emp_Name and all attributes' values appearing in some tuple of ther
EMPLOYEE relation.
-np_Code of all employees who work for the
An expression is said to be safe if all values in its
S.esenrch"
Department, then the construct:
result are from the domain of the expression.Notice
iE,.ErE)_Name, t.HIq)_Code I EI'IPLOYEE(t) AI{D
-d) DEPARTMENT(d) and Dept_narre = "Research" that the result of {t lnot (EMPLOYEE (t)i is unsafe,
a.od d.Dept_Code = t.Dept_Code) since it will, in general include tuples from outside
r the above query, t is the only free variable. It is employee relation.
ren bound successivelyto each tuple that specifies
:he conditions given in the query, and the attributes^ 6.4.6 Quontifiersin SQI
E'p_Narn€ and nnp_Code are retrieved for each The EXISTS function in SQL is similar to the exis-
l-

tential quantifier (3) of the relational calculus. 6.5.3 WFFs


When we write Well-formed formulas(WFFs),formed in accordance
SEIJECT... . . with rules F1-F5in Section6.2.
FROM.
WHERE EXTSTS(SET,ECT X IN RETATIONAT
6.6 SOMEOUERIES
FROMruC ALGEBRA
WHEREP(x) ) t
Consider the following tables structure:
in SQL, it is equivalent to saying that a tuple S-PERSON(S_NO,S_NAME, COMMISSION)
variableX ranging over the relation X is existentially PRODUCT (P_ID, DESCRIPTION)
quantified.The nestedquery on which the EXISTS SALE(DATE, CUSTOMER-NO, S_NO, P-ID, QTY)
function is applied would be correlated with the CUSTOMER(CUSTOMER_NO, C-NAME,
C_ADDRESS)
outer query. That is, the condition P(X) includes
Based on these tables, we shall write queries in
someattributesfrom the outer query relation'
relational algebra to meet the following needs:
The WHERE condition of the outer query Query 1 Get namesof the salesmanwho sold prod-
evaluatesto TRUE if the nested query returns a uct 48.
non-emptyresult that containsone or more tuples. Answer &_NevE (S-PERSON"< SALE))
(on_,o=n,
ug SQf doesnot includea uniaersalquantifier'The
Query 2 Get the names of those customerswho
uniaersalquantifierin relationalcalculuscan be bought table lamps (in addition to other
implementedusing the NOT EXISTS sql command' products).
Answer fic_Nevr (CUSTOMER x (7tr.urro**-*o
(SALE x (ooooou...ots"R*rloN = 'table lamp'
CALCUTUS
6.5 DOMAINRELATIONAT (PRoDUcr)))))
The domain relational calculus differs from the Query 3 Get namesof thosesalespersonswho sold
tuple calculus in that its variables range over all the products.
domains rather than relations. Expressions of the Answer The sequenceto follow in evaluating this
domain calculus are constructed from the following query is to first grouP a list of all products
elements. from the PRODUCTtable by doing projec-
(a) Domain Variables tion on P-ID and then dividing the SALE
(b) Conditions tableby this grouP of P-IDs
(c) Well Formed Formulas (WFFs) SALE +trp rDGRODUCT)
6.5.1 Domoinvoriobles 0€ Thediaisionoperatoris usedin thosequeries
Each domain variable is constrained to range over
thnt inaolaethe phrase"for all obiectshaaing
some specified domain ("Element variable" would
properties".
all thespecified
be a better name, sinie the values are domain ele-
ments,not domains.) Query 4 Get details of customers who bought both
lamps and lamp shades.
6.5.2 Condilions Answer We will first have to select those tuples of
Conditionscan take two foims. These arer table PRODUCT having DESCRIPTION
'lamp'or 'lamp shades'.The result
(i) Simple comparisons of the form x * y, us for the either as
tuple calculus, except that x and y are now will then be projected on P-ID' Next, we
domain variables (or constants). divide SALE by the result from the pre-
(ii) Membership conditions, of the form X (term, vious step to get another relation whose
term, ....).Here X is a relation, and each "term" tuples correspond to those customers who
'lamp' and 'lamP shades'.
is a pair A:V, where A in turn is an attribute of bought both
X and V is either a domain variable or a con- CUSTOMER-NO will be projected from
stant. this relation and joined with the
CUSTOMER relation.
CUSTOMER * ncr.,t o"ER-No (SALE + fip-rp WITHANSWERS
REVIEWOUESTIONS
(QptSCnn'atOW = 'lffip' v DESCRIPTION = 1mP shade')
(PRODUCT))) Fillinthe blonks
Query 5 Find the customer numbers who have
,neverbought product 10.
1. Querylanguagebasedon relationalalgebraare
in nature.
-{nswer Here we will first determinethosecustom-
2. Two operations selection and projection are
ers who have bought product L0. The
operations.
result is then substractedfrom the list of all
3. -- of a relation X, producesa relationY
customers.The resulting relation will con-
suchthat Y containsonly selectedattributesof X.
tain the customers who never bought
4. is the selectionoperationsymbol.
productL0.
5. - is the projectionoperationsymbol'
ficusrousn_No(SAlE) -
l[cusrovrn-No (ot-to='tn(SALE))
Query 6 Get the S-Nos of those salesmenwho sell Answer
at least one of the products sold by sale- 1..procedural 2. unary 3. projection
man 1.56.The result should not include 4. o(sigma) 5. n (pi)
salesman156.
Answer In this query we will have to first obtain a
list of all the productssold by salesman156
EXERC!SE
from the SALE table.The resulting relation Note: Answer all questions.
will then be joined with SALE table. Prpj-
ecting this relation on S-NO gives the list 1. What do you meanby safeexpression?
of S-NOswho ate selling at leastone of the 2. Explain selectionand projectionwith examples
productssold by 156.But the result would 3. Explain different types of joins.
involve saleman155.This should be elimi- 4. Write short note on:
natedusing the MINUS oPerator. (a) Relationalcalculus
(or-"o =,s.(SALE))))- 156
x ttrp-rp
(ns-ruo(SALE (b) Setdifference
74 introductionto DotoboseMonogementSystems

TEST PAPER 6

to DotoboseMonogementSyslems
Introducfion
PARTt (OBJECTIVE to be answeredin 60 Minutes)
QUESTIONS
l. Multiplechoice b. Primary entity d. Secondaryentiby
1.10 Which one of the following is an example of
1.1 If DI, D2,... Dn are domains in a relational
hierarchical database?
model then the relatiein is a table which is a
a. Oracle c. DBII
subsetof
b. Ingress d. SYSTEM2OOO
a. {D1", D2,.....Dn} c. D1 u D2 u Dn
1.1L Which of the following in not a valid unary
b. Dl x D2 x... Dn d. Maximum {D1,D2 .'.
operation in the relational algebra?
Dnl
'1...2 a. Select c. Project
If.E1 and E2 are relational algebra expressions,
b. Min d. Rename
then n'hich of the fr:llowing is NOT a relationai
1.L2 rLelationalAlgebra is
algebraexpression? query
a. Data definition Lan- c. Procedural
a.E1uE2 c. E1-E2
guage language
b. EI/82 d. E1 x E2
b. Meta language d. Non procedural lan-
L.3 Functional deperrdenciesare a generalisation guaSe
of
1.1"3Which one of the following is a binary opera-
a. Key dependencies c. Database dependen-
tion?
cres
a. Project c. Rename
b. Relational depen- d. None of these
b. Select d. None of these
dencies
1.L4 Which clause from the following corresponds
1.4 The operation of a relation X, produces Y, such
to the projection operation of the relational
that Y contains onlv selected attributes of X'
algebra?
Such an operation is
a. From c. Where
a. Projection c. Union
b. Select d. None of these
b. Intersection d. Difference
L.15 Which one of tire clattse is useful in defining
1.5 The table generated on compilation of data
that notion of tuple variables?
stored in language (DDL) are stored in c. From
a. As
a. Data abstraction c. Data file
b. By d. None of these
b. Data Dictionary d. Meta data
1.15 The intersect operation
1.6 The following entities / attributes in a rela-
a. Automatically eliminates duplicates
tional databaseshould not have null values
b. Automatically eliminates duplicates, if we
a. Keys c. Variables
provide all clausewith intersect.
b. Iteiations d. All of these
c. Never eliminates duplicates
1.7 A view of databasettrat appears to an applica-
d. None of the ah.'r-e
tion program is known as
a. Report c. Subschema
2. Select TRUEor FALSEin ihe following
b. Structure d. Scheme
slolements
1.8 The first network databaseis
a. Ingress c. DBTGCodasyl 2.L The universal quantifier in relational caiculus
b. DatabaseI d. SAP can be implemented using the NOT EXISTS
1.9 If entity X is existence-dependenton entity Y constrttctin SQL.
then X is said to be - 2.2 For any two relations q and r
a. Subordinateentify c. Dominant entiW q l l r = q l l ( ql l 4
ond RelotionolColcu,us

2..3 Any equi-join can be expressed using natural 3.10 Rows j. Storageorganization
join and renaming operators. k. Foreignkeys
2,4 In a relational databasekeys are not allowed to
I. EXIST
have null values. Userviews
2.5 Complex entities can be constructed using
4. Fillin the blonksout of the following:
aggregationrelationshiP.
2.6 If two sets of functional dependenciesF and G a. Projection b. Selection c.3
are equivalent, then either F is a subset of G or d. Cardinality e. Duplicate f. Superkey
G is a subset of F. g. Foreign key h. Subordinatei. Keys
entity
2.7 Projection of relation X, produces a relation Y
j. Attributes k.* l. Meta data
such that Y contains only selectedattributes of
m. Three n. division o. cartesian
X.
product
2.8 The functional dependenciesX -+ Y and YZ -+ p. union q. composite r. integrity
W, imply the functional dependency XZ -s W. constraints
2.9 JOIN createsa new databasefile by joining two s. weak entity t. specializa- u. partitioning
or more databasefiles. set tion
2.10 Only two files can be linked for a single SET v.3 w. from
RELATION command,
4.1 In the relational data model, the columns of a
2.11 Tuple relational calculus is declarative and table are called
procedural oriented language. 4.2 The primary k"y index does not allow
2.L2 Selection, projection, union, difference, inter- data in a field.
section and cartesian product operations for- 4.3 of relation X, produces a relation Y
mulate a complete set of relational algebra. such that Y contains only selectedattributes of
2.13 Domain relational calculus restricted to safe X.
domain expressionsin equivalent in expressive 4.4 In a relational data base -- are not
power to the basic relational algebra. allowed to have null values.
2.14 ER diagram functions performed by a system. 4.5 The primary key of a relation is a minimal
2.15 Relational Calculus employs procedural way
of stating queries. 4.5 In a relational database a referential integrity
2.16 QBE is based on the tuple relational calculus. constraint is specified with the help of
l.17 Multiply is a relational algebra operation.
4.7 ANSI / SPARC report defined - lev-
2.18 Equi-join is a natural join with duplicate col-
umns eliminated. els of architecture in a database.
4.8 The number of entities to which another entity
in two columns
3. Motchwords/phroses can be associated via a relationship set is
expressedas - .
3.1 Key a. Attributes
4.9 If an entity X is existence-dependenton'entitv
3.2 ]oin b. Externalmodel
Y, then X is said to be ---.
3.3 View c. Singularset
4.1.0Data about data is normally termed as
3.4 Foreign key d. NOT EXISTS
3.5 Universal e . Minimal set of attrib- 4.11 - primitive set of operations is
quantifiers utes that uniquely needed to express division operation of rela-
identifies a row tional algebra.
3.6 PhysicalModel f. Natural join 4.12 The operationis suitedto queries
3.7 Network data model bo ' Joins table that include the phase "for all"'
3.8 Null h. Tuples 4.13 The operation allows to combine
3.9 Virtual table i. Referential integrity information from any fwo relations.
I 76 Introductionto Dotobore Monoge.ent Syrt.

4.14 A relation that is not part of logical model but Q.4 \Alhatdo you mean by normalization?What
is made visible to a user as a virtual relation is are its advantagesand disadvantages.
calleda(n) _,
Q.5 Considerthe following relations
4.15 A key consisting of more than one column is
PROJECT(ProjectNo,Project_Name,Chiefl
calleda(n) _.
EMPLOYEE(EmpNo,EmpName)
4;1,6A foreign key creates a(n) -...- rela- ASSIGNED(ProjectNo, EmpNo)
tionship between two associatedentities.
(a) GetEmpNoof employeesworking on proj-
4.17 An entity set that does not have sufficient
ectProj302.
attributes to form a primary key is known as (b) Get details of employeesworking on proj-
ectProj302.
4.18 The processof designing sub grouping within (c) Obtain details of employeesworking on
an entity set is _. the DBMSproject.
4.19 The of a query consists of the a. 5 If X ure two relationsasshownbelow:
tuples, which may assigned to the free vari- ""1I
ablesof the well-formed formula. abc bca
dca cdf
4.20 - primitive set of operations is
bfe bfe
needed to express division operation of rela-
tional algebra. X Y
4.21The clause by itself defines a car- Find:
tesianproduct of the relations in the clause. (a) XUY (c) XnY
(b) x-Y (d)XxY

PARTil (DESCR|PT|VE QUESTTONS KeytoTESf PAPER 6


to be answeredin 2 Hours)
Q. 1 Consider the relations L. 1.1(b) 1.2(b) 1.3(a) 1.4(a) 1.s(b) 1.6(a)
Teach(Name, Address, Course) 1.7(c) 1.8(c) 1.e(a) 1.10(d) 1.11(b) 1..r2
Use some standard query commands to do the (c) 1.13(d) 1.14(b) 1.15(d) 1.16(a)
following 2.1(r) 2.2(r) 2.3(r) 2.4(r) 2.s(r) 2.6(F)
(a) Print all the information about teachers 2.7(r) 2.8(r) 2.e(F) 2.10(F) 2.11(F) 2.12
who are teaching the DBMS course. (T) 2.13(F) 2.1,4 (F) 2.15(F) 2.16(T) 2.17(F)
(b) Print the names and addresses of those 2.18(r)
teacherswho teach "DBMS". 3. 3.1(e) 3.2(g) 3.3(b) 3.4(i) 3.5(d) 3.60)
(c) Select the teacher with name "Roshan" 3.7(c) 3.8(a) 3.e(m) 3.10(h)
teaching the course "MIS". 4. 4.1(l a.2@) 4.3(a) 4.4(i) 4.5(0 4.6(e)
Q.2 Explain operations of relational algebra along 4.7@) 4.8(d) 4.e(h) 4.100) 4.11(m) 4.12
with their syntaxes. ( n ) a . 1 3 ( o )a . l a @ ) 4 . 1 5 ( q ) a l . 6 ( r ) a . u g )
Q. Explain natural join with an example.
3 4.18(t) a.19(u) a.20(v) a.21(w)

ANSWERSTO (DESCR|PT|VE
QUESTTONS)
Ans.1 (a) 0 couise=,'DBMS,,
(Teach)
(b) nr.z(o Course
=,,DBMS,(Teach))
n is the projection operation symbol and the subscripts indicates the positions of
the attributes (columns) of the operand (table).
OT
finame, addres, (O Co,rrr" = "DBMS" $each))
bro ond RelotionolColculus

(c) o N"-" = "Roshan"n Course= "MIS" (Teach)

A,ns.2 Operation PurPose Syntax


SETECT It selects all tuples that satisfy the o <selectionconditiop (X)

selectioncondition from a relation X.


PROIECT It produces a new relation with only fi <attribute tirtt (X)

some of the attributes of X, by remov-


ing duplicate tuples.
THETA IOIN It produces all combinations of tuples X, * .joi.,.ondition> Xz
form Xr and X, that satisfies the join
condition.
It produces all the combinations of Xt * .loin.ondition>, Xz or
EQUI IOIN
tuples from Xr and X, that satisfies a X, * (.ioir,uttributes1>)r
join condition with onlY equalitY <join attributes2>1' Xz
comparisons.
*
NATURALIOIN It is same as equi-join except that the Xl .,oir, condition>z X2 or
*
join attributes of X, are not included X1 1.1oin attributes 1>),
*
in the resulting relation; if the join <joinattributes2>1,Xzor X, X,
attributes have the same names, they
do not have to be sPecifiedat all.
UNION It produces a relation that includes all XruX,
the tuples in X, or X, or both X, and
x2.
INTERSECTION It produces a relation that includes all X,nX,
the tuples in both Xt and Xr'
DIFFERENCE It produces a relation that includes all Xt-X,
the tuples in X, that are not in Xr'
CARTESIAN It produces a relation that has the XrxX,
PRODUCT attributes of X, and X, and includes as
tuples all possible combinations of
tuples from X, and Xr.
DIVISION It produces a relation X (X) that X1(Z) + X' (Y)
includes all tuples t [X] in Xt (Z) that
appear in X, in combination with
every tuple from Xr (Y), whete Z
=XuY.
attribute
Ans.3 Natural join is denoted as R o< s. It is applicable only when there is at least one
common to R and S.
To compute R P<S, do the following:
(a) Compute R x S
(b) Select those tuples from R x S whose components corresponding to the common
attributes have the same values.
(c) Project out the columns corresponding to the attributes which have been considered
once.
For example,
Introductlonto Dotobose Monogemenf Systems

ABC BCD
bce ddf
fgh ghk
add ghi
ace cmk

ABCD
R><S fo hk
^f ob hi
ad df
Ans.4 Normalization is the processof reducting the redundancy <lfdata in a relational database
Adaantages
(a) Normalization reduces the unnecessary redundant data.
(b) Data integrity is easily maintained within the database.
(c) Norrnalization makes databaseand application design processesmuch more flex-
ible.
Disadaantages
The disadvantage of normalization is that it produces so many tables with small number of
columns and these columns have to be joined using their primary key or foreign key, rela-
tionships in order to put the information back together so we can use it. For example, a query
may be to retrieve a data from multiple normalized tables. This can result in complicated table
joins.
Ans. 5 (a) = ,pr{o;302,
rs,,pNo(oprojecrNo (ASSIGNED))
(b) EMPLOYEExnE-pNo(oproject#=,pRoJ302,(ASSIGNED))
(c) EMPLOYEE x EE*pN'(ASSIGNEDx (rrproiectNo(oprolect_Name=,DBMS,(PROIECT))))

Ans.6 (a) abc


dca
Xt.rY = bfe
bca
cdf

(b) X-Y = abc


dca

l
Relotionol ebro ond RelqtionolColculus

(c)
XnY = bfe

(d)
abcbca
abccdf
abcbfe
dcabca
XxY = dcacdf
dcabfe
bfebca
bfecdf
bfebfe

You might also like