Sie sind auf Seite 1von 99

GURU NANAK Engineering College

Ibrahimpatnam, R R District 501 50 !A" #"$


Department o% Comp&ter 'cience
Engineering
Database (anagement ')stems
*ab (an&al +C' 0515,-
II . /ech I 'emester +.ranch0 C'E-
IN'/RUC/1R' 0 (r" Rishi 'a)al, 21D
(r" 'ai3&l&, Asst" #ro%"
Document NO:
GNEC/CSE/LAB
MANUAL/DBMS
Date of Issue: Compiled b
Aut!o"i#ed b
Date of "e$ision %e"ified b
#R1GRA((ER' 0 1" K"Ra4i
5" /ri4eni 6oshi
DBMS Lab Manual
INDE7
'" No Contents #age" no
& Lab Ob'ecti$e
(
) Int"oduction About Lab
*
(
Standa"d Ope"atin+ ,"ocedu"e -
SO,
.
( Guidelines to Students
/
*
Desc"iption about S0L1 ,L/S0L
statements and D)23
4
5
List of Lab E6e"cises
*3& Sllabus ,"o+"ams 78N9U:
*3) Additional ,"o+"ams
;
. Bac<+"ound 9!eo"
&*
/ Solutions fo" ,"o+"ams
)=
4 ,L>S?l ,"o+"ams
5=
; Additional %i$a 0uestion
44
&= @efe"ences
;*
K.Ravi 2
DBMS Lab Manual
*A. 1.6EC/I8E
Upon successful completion of t!is Lab t!e student Aill be able to:
C"eatin+ database ob'ects
Modifin+ database ob'ects
Manipulatin+ t!e data
@et"ie$in+ t!e data f"om t!e database se"$e"
,e"fo"min+ database ope"ations in a p"ocedu"al manne" usin+ pl/s?l
,e"fo"min+ database ope"ations 7c"eate1 update1 modif1 "et"ie$e1
etc31: usin+ f"ont>end tools li<e D)23
Desi+n and De$elop applications li<e ban<in+1 "ese"$ation sstem1 etc31
K.Ravi 3
DBMS Lab Manual
IN/R1DUC/I1N A.1U/ *A.
9!e"e a"e .. sstems 7 Compa? ,"esa"io : installed in t!is
Lab3 9!ei" confi+u"ations a"e as folloAs :
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
Mouse : Optical Mouse
NetAo"< Inte"face ca"d : ,"esent
'o%t9are
All sstems a"e confi+u"ed in DUA* .11/ mode i3e31 Students can
boot f"om DindoAs E, o" Linu6 as pe" t!ei" lab "e?ui"ement3 9!is is
$e" useful fo" students because t!e a"e familia" Ait! diffe"ent
Ope"atin+ Sstems so t!at t!e can e6ecute t!ei" p"o+"ams in
diffe"ent p"o+"ammin+ en$i"onments3
Eac! student !as a sepa"ate lo+in fo" database access
1racle :i client $e"sion is installed in all sstems3 On t!e se"$e"1
account fo" eac! student !as been c"eated3
9!is is $e" useful because students can sa$e t!ei" Ao"<
7scena"iosF1 pl / s?l p"o+"ams1 data "elated p"o'ects1 etc: in t!ei"
oAn accounts3 Eac! student Ao"< is safe and secu"e f"om ot!e"
students3
K.Ravi 4
DBMS Lab Manual
Latest 9ec!nolo+ies li<e D1/ NE/ and 65EE a"e installed in some
sstems3 Befo"e submittin+ t!ei" final p"o'ect1 t!e can sta"t doin+
mini p"o'ect f"om )
nd
ea" onAa"ds3
(A'( !(acro Assembler$ is installed in all t!e sstems
Students can e6ecute t!ei" assembl lan+ua+e p"o+"ams usin+
MASM3 MASM is $e" useful students because A!en t!e e6ecute
t!ei" p"o+"ams t!e can see contents of #rocessor Registers
and !oA each instr&ction is bein+ e6ecuted in t!e C#U3
@ational @ose SoftAa"e is installed in some sstems
Usin+ t!is softAa"e1 students can depict UML dia+"ams of t!ei"
p"o'ects3
'o%t9ares installe3 0 C1 CGG1 8D2&351 MASM1 OHHICE>E,1 8)EE and
DO9 NE91 @ational @ose3
')stems are pro4i3e3 %or st&3ents in the 101 ratio"
')stems are assigne3 n&mbers an3 same s)stem is allotte3 %or
st&3ents 9hen the) 3o the lab"

K.Ravi 5
DBMS Lab Manual
'/ANDARD 1#ERA/ING #R1CEDURE '1#
a: E6planation on todaFs e6pe"iment b t!e conce"ned facult usin+
OC,/,,9 co$e"in+ t!e folloAin+ aspects: )5 mins3
&: Name of t!e e6pe"iment/Aim
): SoftAa"e/Ca"dAa"e "e?ui"ed
(: Al+o"it!m
*: 9est Data
&: %alid data sets
): Limitin+ $alue sets
(: In$alid data sets
b: D"itin+ of sou"ce p"o+"am b t!e students )5
min3
c: Compilin+ and e6ecution of t!e p"o+"am
&== mins3
;riting o% the e<periment in the 1bser4ation .oo= :
9!e students Aill A"ite t!e todaFs e6pe"iment in t!e Obse"$ation boo<
as pe" t!e folloAin+ fo"mat:
a: Name of t!e e6pe"iment/Aim
b: SoftAa"e/Ca"dAa"e "e?ui"ed
c: Al+o"it!m
d: Sou"ce ,"o+"am
e: 9est Data
a3 %alid data sets
b3 Limitin+ $alue sets
c3 In$alid data sets
f: @esults fo" diffe"ent data sets
+: %i$a>%oc 0uestions and AnsAe"s
!: E""o"s obse"$ed 7if an: du"in+ compilation/e6ecution
K.Ravi 6
DBMS Lab Manual
i: Si+natu"e of t!e Hacult
K.Ravi 7
DBMS Lab Manual
G&i3elines to 't&3ents
E?uipment in t!e lab fo" t!e use of student communit3 Students need
to maintain a p"ope" deco"um in t!e compute" lab3 Students must use
t!e e?uipment Ait! ca"e3 An dama+e is caused is punis!able3
Students a"e "e?ui"ed to ca"" t!ei" obse"$ation / p"o+"ams boo< Ait!
completed e6e"cises A!ile ente"in+ t!e lab3
Students a"e supposed to occup t!e mac!ines allotted to t!em and
a"e not supposed to tal< o" ma<e noise in t!e lab3 9!e allocation is put
up on t!e lab notice boa"d3
Lab can be used in f"ee time / lunc! !ou"s b t!e students A!o need
to use t!e sstems s!ould ta<e p"io" pe"mission f"om t!e lab in>
c!a"+e3
Lab "eco"ds need to be submitted on o" befo"e date of submission3
Students a"e not supposed to use flopp dis<s
K.Ravi 8
DBMS Lab Manual
2o9 to ;rite an3 e<ec&te s>l, pl?s>l comman3s?programs0
&:3 Open ou" o"acle application b t!e folloAin+ na$i+ation
Sta"t>Iall p"o+"ams>Io"acle o"a!ome3>Iapplication
de$elopment>Is?l3
):3 Jou Aill be as<ed fo" use" name1 pass Ao"d and !ost st"in+
Jou !a$e to ente" use" name1 pass Ao"d and !ost st"in+ as +i$en
b t!e administ"ato"3 It Aill be diffe"ent f"om one use" to anot!e" use"3
(:3 Upon successful lo+in ou Aill +et S0L p"ompt 7S0LI:3
In tAo Aas ou can A"ite ou" p"o+"ams:
a:3 di"ectl at S0L p"ompt
b:3 o" in s?l edito"3
If ou tpe ou" p"o+"ams at s?l p"ompt t!en sc"een Aill loo< li<e folloA:
S0LI SELEC9 ename1empno1
) sal f"om
( empK
A!e"e ) and ( a"e t!e line numbe"s and "est is t!e command /p"o+"amLL
to e6ecute abo$e p"o+"am/command ou !a$e to p"ess M/F t!en ente"3
Ce"e editin+ t!e p"o+"am is someA!at difficultK if ou Aant to edit t!e
p"e$ious command t!en ou !a$e to open s?l edito" 7b default it displas
t!e s?l buffe" contents:3 B +i$in+ MedF at s?l p"ompt37t!is is A!at I
mentioned as a second met!od to tpe/ente" t!e p"o+"am:3
in t!e s?l edito" ou can do all t!e fo"mattin+/editin+/file ope"ations di"ectl
b selectin+ menu options p"o$ided b it3
9o e6ecute t!e p"o+"am A!ic! sa$edK do t!e folloAin+
S0LI N p"o+"amname3s?l
O"
S0LI @un p"o+"amname3s?l
9!en p"ess MOF <e and ente"3
9!is !oA Ae can A"ite1 edit and e6ecute t!e s?l command and p"o+"ams3
AlAas ou !a$e to sa$e ou" p"o+"ams in ou" oAn lo+ins3
K.Ravi 9
DBMS Lab Manual
*ist o% *ab E<ercises
')llab&s #rograms !6N/U$
'" No Name o% the program
1 Database 'chema %or a c&stomer@sale scenario
Custome"7C&st i3 0 integer, custPname: st"in+:
Item7itemAi30 integer, itemPname: st"in+1 p"ice: inte+e":
Sale7billAno0 integer, billPdate: date1 c&stAi30 integer,
itemAi30 integer1 ?tPsold: inte+e":
Ho" t!e abo$e sc!ema1 pe"fo"m t!e folloAin+Q
a: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b: Inse"t a"ound &= "eco"ds in eac! of t!e tables
c: List all t!e bills fo" t!e cu""ent date Ait! t!e custome" names
and item numbe"s
d: List t!e total Bill details Ait! t!e ?uantit sold1 p"ice of t!e
item and t!e final amount
e: List t!e details of t!e custome" A!o !a$e bou+!t a p"oduct
A!ic! !as a p"iceI)==
f: Gi$e a count of !oA man p"oducts !a$e been bou+!t b
eac! custome"
+: Gi$e a list of p"oducts bou+!t b a custome" !a$in+
custPid as 5
!: List t!e item details A!ic! a"e sold as of toda
i: C"eate a $ieA A!ic! lists out t!e billPno1 billPdate1 custPid1
itemPid1 p"ice1 ?tPsold1 amount3
5 Database 'chema %or a 't&3ent *ibrar) scenario
Student7't&3Ano 0 integer, StudPname: st"in+:
Membe"s!ip7(emAno0 integer1 't&3Ano0 integer:
Boo<7boo=Ano0 integer1 boo<Pname:st"in+1 aut!o": st"in+:
IssP"ec!issAno0integer1 issPdate: date1 (emAno0 integer1
boo=Ano0 integer:
K.Ravi 10
DBMS Lab Manual
Ho" t!e abo$e sc!ema1 pe"fo"m t!e folloAin+Q
a: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b: Inse"t a"ound &= "eco"ds in eac! of t!e tables
c: List all t!e student names Ait! t!ei" membe"s!ip numbe"s
d: List all t!e issues fo" t!e cu""ent date Ait! student and
Boo< names
e: List t!e details of students A!o bo""oAed boo< A!ose
aut!o" is C8DA9E
f: Gi$e a count of !oA man boo<s !a$e been bou+!t b
eac! student
+: Gi$e a list of boo<s ta<en b student Ait! studPno as 5
!: List t!e boo< details A!ic! a"e issued as of toda
i: C"eate a $ieA A!ic! lists out t!e issPno1 iss Pdate1
studPname1 boo< name
': C"eate a $ieA A!ic! lists t!e dail issues>date Aise fo" t!e
last one Aee<
B Database 'chema %or a Emplo)ee@pa) scenario
emploee7empAi3 0 integer 1 empPname: st"in+:
depa"tment73eptAi30 integer1 deptPname:st"in+:
padetails7empAi3 0 integer1 3eptAi30 integer1 basic: inte+e"1
deductions: inte+e"1 additions: inte+e"1 DO8: date:
pa"oll!empAi3 0 integer1 paPdate: date:
Ho" t!e abo$e sc!ema1 pe"fo"m t!e folloAin+Q
a: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b: Inse"t a"ound &= "eco"ds in eac! of t!e tables
c: List t!e emploee details depa"tment Aise
d: List all t!e emploee names A!o 'oined afte" pa"ticula"
date
e: List t!e details of emploees A!ose basic sala" is
betAeen &=1=== and )=1===
f: Gi$e a count of !oA man emploees a"e Ao"<in+ in eac!
depa"tment
+: Gi$e a names of t!e emploees A!ose netsala"I&=1===
!: List t!e details fo" an emploeePidR5
i: C"eate a $ieA A!ic! lists out t!e empPname1 depa"tment1
basic1 dedeuctions1 netsala"
': C"eate a $ieA A!ic! lists t!e empPname and !is netsala"
C Database 'chema %or a 8i3eo *ibrar) scenario
Custome"7custPno: inte+e"1custPname: st"in+:
K.Ravi 11
DBMS Lab Manual
Membe"s!ip7(emAno0 integer1 c&stAno0 integer:
Cassette7cassAno0integer1 cassPname:st"in+1 Lan+ua+e:
St"in+:
IssP"ec!issAno0 integer1 issPdate: date1 memAno0 integer1
cassAno0 integer:
Ho" t!e abo$e sc!ema1 pe"fo"m t!e folloAin+Q
a: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b: Inse"t a"ound &= "eco"ds in eac! of t!e tables
c: List all t!e custome" names Ait! t!ei" membe"s!ip
numbe"s
d: List all t!e issues fo" t!e cu""ent date Ait! t!e custome"
names and cassette names
e: List t!e details of t!e custome" A!o !as bo""oAed t!e
cassette A!ose title is S 9!e Le+endT
f: Gi$e a count of !oA man cassettes !a$e been bo""oAed
b eac! custome"
+: Gi$e a list of boo< A!ic! !as been ta<en b t!e student
Ait! memPno as 5
!: List t!e cassettes issues fo" toda
i: C"eate a $ieA A!ic! lists outs t!e issPno1 issPdate1
custPname1 cassPname
': C"eate a $ieA A!ic! lists issues>date Aise fo" t!e last one
Aee<
5 Database 'chema %or a st&3ent@*ab scenario
Student7st&3Ano0 integer1 studPname: st"in+1 class0 string:
Class7class0 string, 3escrip0 string:
Lab7machAno0 integer1 LabPno: inte+e"1 desc"iption: St"in+:
Allotment7't&3Ano0 Integer, machAno0 integer, 3a)o%
9ee=0 string$
Ho" t!e abo$e sc!ema1 pe"fo"m t!e folloAin+Q
a: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b: Inse"t a"ound &= "eco"ds in eac! of t!e tables
c: List all t!e mac!ine allotments Ait! t!e student names1
lab and mac!ine numbe"s
d: List t!e total numbe" of lab allotments da Aise
e: Gi$e a count of !oA man mac!ines !a$e been allocated
to t!e MCSI9F class
f: Gi$e a mac!ine allotment etails of t!e studPno 5 Ait! !is
pe"sonal and class details
+: Count fo" !oA man mac!ines !a$e been allocatedin
*abAno 1 fo" t!e da of t!e Aee< as SMondaT
!: CoA man students class Aise !a$e allocated mac!ines in
K.Ravi 12
DBMS Lab Manual
t!e labs
i: C"eate a $ieA A!ic! lists out t!e studPno1 studPname1
mac!Pno1 labPno1 daofAee<
': C"eate a $ieA A!ic! lists t!e mac!ine allotment details fo"
S9!u"sdaT3
D"ite a p"o+"am to find la"+est numbe" f"om t!e +i$en t!"ee
numbe"s3
, Simple p"o+"ams usin+ loop1 A!ile and fo" ite"ati$e cont"ol
statement3
D D"ite a p"o+"am to c!ec< A!et!e" t!e +i$en numbe" is
A"mst"on+ o" not
: D"ite a p"o+"am to +ene"ate all p"ime numbe"s beloA &==3
10 D"ite a p"o+"am to demonst"ate t!e GO9O statement3
11 D"ite a p"o+"am to demonst"ate Utpe and U"oAtpe att"ibutes
15 D"ite a p"o+"am to demonst"ate p"edefined e6ceptions
1B D"ite a p"o+"am to demonst"ate use" defined e6ceptions
1C C"eate a cu"so"1 A!ic! displas all emploee numbe"s and
names f"om t!e EM, table3
15 C"eate a cu"so"1 A!ic! update t!e sala"ies of all emploees as
pe" t!e +i$en data3
1 C"eate a cu"so"1 A!ic! displas names of emploees !a$in+
sala" I 5====3
1, C"eate a p"ocedu"e to find "e$e"se of a +i$en numbe"
1D C"eate a p"ocedu"e to update t!e sala"ies of all emploees as
pe" t!e +i$en data
1: C"eate a p"ocedu"e to demonst"ate IN1 OU9 and INOU9
pa"amete"s
50 C"eate a function to c!ec< A!et!e" +i$en st"in+ is palind"ome o"
not3
51 C"eate a function to find sum of sala"ies of all emploees
Ao"<in+ in depa"t numbe" &=3
55 C"eate a t"i++e" befo"e/afte" update on emploee table fo" eac!
"oA/statement3
5B C"eate a t"i++e" befo"e/afte" delete on emploee table fo" eac!
"oA/statement3
5C C"eate a t"i++e" befo"e/afte" inse"t on emploee table fo" eac!
"oA/statement3
55 C"eate a Ho"m to displa emploee details usin+ S0L
5 C"eate a @epo"t to +ene"ate all emploee annual sala"iesL3
A33itional #rograms
K.Ravi 13
DBMS Lab Manual
'" No Name o% the #rogram
1 C"eate a fo"m usin+ Ho"ms .i to displa Emploee table
data3
5 C"eate a Maste"/details "elations!ip fo"m A!ic!
pe"fo"m Add NeA1 Sea"c!1 Delete1 Sa$e and Update on
t!e "eco"ds
B Gene"ate a "epo"t to calculate emploeeFs sala"ies
depa"tment Aise f"om emploee table3
C C"eate a @epo"t to +ene"ate t!e details of emploee
table includin+ sum and a$e"a+e sala"ies depa"tment
Aise3
K.Ravi 14
DBMS Lab Manual
.ac=gro&n3 /heor)
O"acle Ao"<+"oup o" se"$e" is t!e la"+est sellin+ @DBMS p"oduct3it is
estimated t!at t!e combined sales of bot! t!ese o"acle database p"oduct
account fo" a"oud 4=U of t!e @DBMSsstems sold Ao"ldAide3
9!ese p"oducts a"e constantl unde"+oin+ c!an+e and e$ol$in+3 9!e natu"al
lan+ua+e of t!is @DBMS p"oduct is ANSI S0L1,L/S0L a supe"set of ANSI
S0L3o"acle 4i and ;i also unde" stand S0L83
O"acle co"p !as also inco"po"ated a full>fled+ed 'a$a $i"tual mac!ine into its
database en+ine3since bot! e6ecutable s!a"e t!e same memo" space t!e
8%M can communicate Dit! t!e database en+ine Ait! ease and !as di"ect
access to o"acle tables and t!ei" data3
S0L is st"uctu"e ?ue" lan+ua+e3S0L contains diffe"ent data tpes t!ose a"e
&3 c!a"7si#e:
)3 $a"c!a")7si#e:
(3 date
*3 numbe"7p1s:
53 lon+
.3 "aA/lon+ "aA
Di%%erent t)pes o% comman3s in 'E*0
A). DD* comman3s0 @ 9o c"eate a database ob'ects
B). D(* comman3s0 @ 9o manipulate data of a database ob'ects
C). DE* comman30 @ 9o "et"ie$e t!e data f"om a database3
D). DC*?D/* comman3s0 @ 9o cont"ol t!e data of a databaseL
DD* comman3s0
1" /he Create /able Comman30 @ it defines eac! column of t!e table
uni?uel3 Eac! column !as minimum of t!"ee att"ibutes1 a name 1 data tpe
and si#e3
')nta<0
Create table Vtable nameI 7Vcol&I VdatatpeI7Vsi#eI:1Vcol)I
VdatatpeIVsi#eI::K
E<0
c"eate table emp7empno numbe"7*: p"ima" <e1 ename c!a"7&=::K
K.Ravi 15
DBMS Lab Manual
5" (o3i%)ing the str&ct&re o% tables"
a:add neA columns
')nta<0
Alter table VtablenameI add7VneA colIVdatatpe7si#e:1VneA
colIdatatpe7si#e::K
E<0
alte" table emp add7sal numbe"7/1)::K
B" Dropping a col&mn %rom a table"
')nta<0
Alte" table VtablenameI d"op column VcolIK
E<0
alte" table emp d"op column salK
C" (o3i%)ing e<isting col&mns"
')nta<0
Alte" table VtablenameI modif7VcolIVneAdatatpeI7VneAsi#eI::K
E<0
alte" table emp modif7ename $a"c!a")7&5::K
5" Renaming the tables
')nta<0
Rename VoldtableI to VneA tableIK
E<0
"ename emp to emp&K
" tr&ncating the tables"
')nta<0
/r&ncate table VtablenameIK
E<0
t"unc table emp&K
K.Ravi 16
DBMS Lab Manual
," Destro)ing tables"
')nta<0
Drop table VtablenameIK
E<0
d"op table empK
D(* comman3s0
D" Inserting Data into /ables0 @ once a table is c"eated t!e most natu"al
t!in+ to do is load t!is table Ait! data to be manipulated late"3
')nta<0
inse"t into VtablenameI 7Vcol&I1Vcol)I: $alues7Ve6pI1Ve6pI:K
:" Delete operations"
a$ "emo$e all "oAs
')nta<0
delete f"om VtablenameIK
b$ "emo$al of a specified "oA/s
')nta<0
delete f"om VtablenameI A!e"e VconditionIK
10" Up3ating the contents o% a table"
a$ updatin+ all "oAs
')nta<0
Update VtablenameI set VcolIRVe6pI1VcolIRVe6pIK
b$ updatin+ seleted "eco"ds3
Snta6:
Update VtablenameI set VcolIRVe6pI1VcolIRVe6pI
A!e"e VconditionIK
11" /)pes o% 3ata constrains"
a$ not null const"aint at column le$el3
')nta<0
VcolIVdatatpeI7si#e:not null
b$ uni?ue const"aint
')nta<0
K.Ravi 17
DBMS Lab Manual
Uni?ue const"aint at column le$el3
VcolIVdatatpeI7si#e:uni?ueK
c$ uni?ue const"aint at table le$el:
')nta<0
C"eate table
tablename7colRfo"mat1colRfo"mat1uni?ue7Vcol&I1Vcol)I:K
3$ p"ima" <e const"aint at column le$el
')nta<0
VcolIVdatatpeI7si#e:p"ima" <eK
e$ p"ima" <e const"aint at table le$el3
')nta<0
C"eate table tablename7colRfo"mat1colRfo"mat
p"ima" <e7col&I1Vcol)I:K
%$ fo"ei+n <e const"aint at column le$el3
')nta<0
VcolIVdatatpeI7si#eI: "efe"ences VtablenameIWVcolIXK
g$ fo"ei+n <e const"aint at table le$el
')nta<0
fo"ei+n <e7VcolIW1VcolIX:"efe"ences VtablenameIW7VcolI1VcolI:
h$ c!ec< const"aint
c!ec< const"aint const"aint at column le$el3
')nta<0 VcolIVdatatpeI7si#e: c!ec<7Vlo+ical e6p"essionI:
i$ c!ec< const"aint const"aint at table le$el3
')nta<0 c!ec<7Vlo+ical e6p"essionI:
K.Ravi 18
DBMS Lab Manual
DE* Comman3s0
15" 8ie9ing 3ata in the tables: > once data !as been inse"ted into a
table1 t!e ne6t most lo+ical ope"ation Aould be to $ieA A!at !as been
inse"ted3
a$ all "oAs and all columns
')nta<0
Select VcolI to Vcol nI f"om tablenameK
Select Y f"om tablenameK
1B" Filtering table 3ata: > A!ile $ieAin+ data f"om a table1 it is "a"e t!at
all t!e data f"om table Aill be "e?ui"ed eac! time3 Cence1 s?l must +i$e us a
met!od of filte"in+ out data t!at is not "e?ui"ed data3
a$ Selected columns and all "oAs:
')nta<0
select Vcol&I1Vcol)I f"om VtablenameIK
b$ selected "oAs and all columns:
')nta<0
select Y f"om VtablenameI A!e"e VconditionIK
c$ selected columns and selected "oAs
')nta<0
select Vcol&I1Vcol)I f"om VtablenameI A!e"eVconditionIK
1C" 'orting 3ata in a table"
')nta<0
Select Y f"om VtablenameI o"de" b Vcol&I1Vcol)I VWso"to"de"XIK
DC* comman3s0
O"acle p"o$ides e6tensi$e featu"e in o"de" to safe+ua"d info"mation sto"ed in
its tables f"om unaut!o"aised $ieAin+ and dama+e39!e "i+!ts t!at alloA t!e
use" of some o" all o"acle "esou"ces on t!e se"$e" a"e called p"i$ile+es3
a$ G"ant p"i$ile+es usin+ t!e G@AN9 statement
9!e +"ant statement p"o$ides $a"ious tpes of access to database ob'ects
suc! as tables1$ieAs and se?uences and so on3
K.Ravi 19
DBMS Lab Manual
')nta<0
G@AN9 Vob'ect p"i$ile+esI
ON Vob'ectnameI
9OVuse"nameI
WDI9C G@AN9 O,9IONXK
b$ @eo<e pe"missions usin+ t!e @E%O2E statement:
9!e @E%O2E statement is used to den t!e G"ant +i$en on an ob'ect3
')nta<0
@E%O2EVob'ect p"i$ile+eI
ON
H@OMVuse" nameIK
K.Ravi 20
DBMS Lab Manual
'ol&tions %or programs !6N/U ')llab&s$
1" Database 'chema %or a c&stomer@sale scenario
Custome"7C&st i3 0 integer, custPname: st"in+:
Item7itemAi30 integer1 itemPname: st"in+1 p"ice: inte+e":
Sale7billAno0 integer1 billPdate: date1 c&stAi30 integer, itemAi30
integer1 ?tPsold: inte+e":
Ho" t!e abo$e sc!ema1 pe"fo"m t!e folloAin+Q
a: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b: Inse"t a"ound &= "eco"ds in eac! of t!e tables
c: List all t!e bills fo" t!e cu""ent date Ait! t!e custome" names and item
numbe"s
d: List t!e total Bill details Ait! t!e ?uantit sold1 p"ice of t!e item and
t!e final amount
e: List t!e details of t!e custome" A!o !a$e bou+!t a p"oduct A!ic! !as
a p"iceI)==
f: Gi$e a count of !oA man p"oducts !a$e been bou+!t b eac!
custome"
+: Gi$e a list of p"oducts bou+!t b a custome" !a$in+ custPid as 5
!: List t!e item details A!ic! a"e sold as of toda
i: C"eate a $ieA A!ic! lists out t!e billPno1 billPdate1 custPid1 itemPid1
p"ice1 ?tPsold1 amount
j) C"eate a $ieA A!ic! lists t!e dail sales date Aise fo" t!e last one
Aee<
K.Ravi 21
DBMS Lab Manual
Aim: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints and Inse"t
a"ound &= "eco"ds in eac! of t!e tables
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O@ACLE

S0LI c"eate table custome"& 7custPid numbe"75: p"ima" <e1 custPname
$a"c!a")7&5::K
1&tp&t0 9able c"eated3
S0LI desc custome"&K
1&tp&t0
Name NullZ 9pe
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>>>>>>>>>>>>>>>
CUS9PID NO9 NULL NUMBE@75:
CUS9PNAME %A@CCA@)7&5:
8ali3 /est Data
b$ S0LI inse"t into custome"& $alues7[custid1\[custname\:K
S0LI select Y f"om custome"&K
1&tp&t0
CUS9PID CUS9PNAME
>>>>>>>>>> >>>>>>>>>>>>>>>
&== "amu
&=& <amal
&=) "a'u
&=( "a'u sunda"am
&=* laA"ence
S0LI c"eate table item7itemPid numbe"7*: p"ima" <e1
itemPname $a"c!a")7&5:1p"ice numbe"7.1)::K
S0LI dsec item
1&tp&t0
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
K.Ravi 22
DBMS Lab Manual
CustPid NO9 NULL NUMBE@7*:
ItemPname %A@CCA@)7&5:
,@ICE NUMBE@7.1):
S0LIinse"t into item $alues7[itemPid1F[itemPnameF1[p"ice:K


S0LI select Y f"om itemK
1&tp&t0
I9EMPID I9EMPNAME ,@ICE
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
)((* +ee"a .3)5
*5() co"n soup (*3.5
)&)* las c!ips )=
*5(& setAet ;;3;;
)(&; du"acell *535
S0LIc"eate table sale7billPno numbe"75: p"ima" <e1billPdate date1 custPid
numbe"75: "efe"ences custome"7custPid:1 itemPid numbe"7*: "efe"ences
item7itemPid:1?tPsold numbe"7*::K
1&t p&t: 9able C"eated3
S0LIdsec sale
1&tp&t0
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
BILLPNO NO9 NULL NUMBE@7*:
BILLPDA9E DA9E
CUS9PID NUMBE@75:
I9EMPID NUMBE@7*:
09JPSOLD NUMBE@7*:
S0LIinse"t into Sale $alues7[billPno1 F[billPdateF1
[custPid1 [itemPid1 [?tPsold:K
S0LIselect Y f"om saleK
1&tp&t0
BILLPNO BILLPDA9E CUS9PID I9EMPID 09JPSOLD
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL333
&*5= =*>8AN>=. &== )&)* )
&*5& =*>8AN>=. &=& )(&; &
&*5) =*>8AN>=. &=( *5(& )
&*5( =*>8AN>=. &=) )((* (
K.Ravi 23
DBMS Lab Manual
&*5* =*>8AN>=. &=* *5() (
c$ List all t!e bills fo" t!e cu""ent date Ait! t!e custome" names and
item numbe"s
S0LI select c3custname1 i3itemid1 s3billno f"om custome" c1 item I1
sale s
A!e"e c3custidRs3custid and
s3billdateRtoPc!a"7ssdate:K
CUS9NAME I9EMID BILLNO
>>>>>>>>>>>>> >>>>>>>>> >>>>>>>>>
8o!n 5==& (()
3$ List t!e total Bill details Ait! t!e ?uantit sold1 p"ice of t!e item and
t!e final amount
S0LI select i3p"ice1 s3?t17i3p"iceYs3?t: total f"om item I1 sale s A!e"e
i3itemidRs3itemidK
,@ICE 09J 9O9AL
>>>>>>> >>>>> >>>>>>>>
&)= ) )*=
)= ( .=
5 ) &=
&= & &=
(5= * &*==
e$ List t!e details of t!e custome" A!o !a$e bou+!t a p"oduct A!ic! !as
a p"iceI)==
S0LI select c3custid1 c3custname f"om custome" c1 sale s1 item i A!e"e
i3p"iceI)== and
c3custidRs3custid and i3itemidRs3itemidK
CUS9ID CUS9NAME
>>>>>>>>> >>>>>>>>>>>>>>
* duff
%$ Gi$e a count of !oA man p"oducts !a$e been bou+!t b eac!
custome"
S0LI select custid1 count7itemid: f"om sale +"oup b custidK
CUS9ID COUN97I9EMID:
>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>
& )
K.Ravi 24
DBMS Lab Manual
( &
* &
5 &
g$ Gi$e a list of p"oducts bou+!t b a custome" !a$in+ custPid as 5
S0LI select i3itemname f"om item i1 sale s A!e"e s3custidR5 and
i3itemid>s3itemidK
I9EMNAME
>>>>>>>>>>>>>>
,ens
h$ List t!e item details A!ic! a"e sold toda
S0LI select i3itemid1 i3itemname f"om item I1 sale s A!e"e
i3itemidRs3itemid
and s3billdateRtoPc!a"7ssdate:K
I9EMID I9EMNAME
>>>>>>>>> >>>>>>>>>>>>>
&)(* pencil
i$ C"eate a $ieA A!ic! lists out t!e billPno1 billPdate1 custPid1
itemPid1 p"ice1 ?tPsold1 amount
S0LIc"eate $ieA cust as 7select s3billno1 s3billdate1 c3custid1 i3 iitemid1
i3p"ice1 s3?t f"om custome" c1sale s item I A!e"e
c3custidRs3custid and i3itemidRs3itemid:K
$ieA c"eated3
S0LIselect Y f"om custK
BILLNO BILLDA9E CUS9ID I9EMID ,@ICE 09J
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
(*() &)>8AN>=. ( ()** &)= )
**)* )=>HEB>=. & (*5. )= (
(() &(>MA@>=. & &)(* 5 )
)(*( &=>MA@ 5 5==& &= &
&((& &&>MA@>=. * /.//. (5= *
8i4a@8oce0
0&3 D!at is S0LZ
K.Ravi 25
DBMS Lab Manual
Ans: St"uctu"ed 0ue" Lan+ua+e
2. What is database?
A database is a lo+icall co!e"ent collection of data Ait! some in!e"ent
meanin+1 "ep"esentin+ some aspect of "eal Ao"ld and A!ic! is desi+ned1
built and populated Ait! data fo" a specific pu"pose3
3. What is DBMS?
It is a collection of p"o+"ams t!at enables use" to c"eate and maintain
a database3 In ot!e" Ao"ds it is +ene"al>pu"pose softAa"e t!at p"o$ides t!e
use"s Ait! t!e p"ocesses of defining1 constructing and manipulating t!e
database fo" $a"ious applications3
4. What is a Database system?
9!e database and DBMS softAa"e to+et!e" is called as Database
sstem3
5. d!antages of DBMS?
@edundanc is cont"olled3
Unaut!o"ised access is "est"icted3
,"o$idin+ multiple use" inte"faces3
Enfo"cin+ inte+"it const"aints3
,"o$idin+ bac<up and "eco$e"3
". Disad!antage in #ile $rocessing System?
Data "edundanc [ inconsistenc3
Difficult in accessin+ data3
Data isolation3
Data inte+"it3
Concu""ent access is not possible3
Secu"it ,"oblems3
K.Ravi 26
DBMS Lab Manual
5" Database 'chema %or a 't&3ent *ibrar) scenario
Student7't&3Ano 0 integer, StudPname: st"in+:
Membe"s!ip7(emAno0 integer1 't&3Ano0 integer:
Boo<7boo=Ano0 integer1 boo<Pname:st"in+1 aut!o": st"in+:
IssP"ec!issAno0integer1 issPdate: date1 (emAno0 integer1 boo=Ano0
integer:
For the abo4e schema, per%orm the %ollo9ingG
a$ C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b$ Inse"t a"ound &= "eco"ds in eac! of t!e tables
c$ List all t!e student names Ait! t!ei" membe"s!ip numbe"s
3$ List all t!e issues fo" t!e cu""ent date Ait! student and Boo< names
e$ List t!e details of students A!o bo""oAed boo< A!ose aut!o" is
C8DA9E
%$ Gi$e a count of !oA man boo<s !a$e been bou+!t b eac! student
g$ Gi$e a list of boo<s ta<en b student Ait! studPno as 5
h$ List t!e boo< details A!ic! a"e issued as of toda
i$ C"eate a $ieA A!ic! lists out t!e issPno1 iss Pdate1 studPname1 boo<
name
H$ C"eate a $ieA A!ic! lists t!e dail issues>date Aise fo" t!e last one
Aee<
K.Ravi 27
DBMS Lab Manual
AI(0 C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
Inse"t a"ound &= "eco"ds in eac! of t!e tables
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle
S0LIc"eate table student7studPno numbe"75: p"ima" <e1studPname
$a"c!a")7&5::K
S0LIdesc studentK
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
S9UDPNO NO9 NULL NUMBE@75:
S9UDPNAME %A@CAC@)7&5:
8ali3 /est Data0
S0LIinse"t into student $alues7[studPno1F[studPnameF:K
S0LIselect Y f"om studentK
S9UDPNO S9UDPNAME
33333333333333333333333333333333333333333333333333333333333333333333
5=4 CA@ISC
5&( BALA8I
5&4 @A2ESC
5)* ,A%AN
5(* 8OJCE
S0LIc"eate table membe"s!ip7memPno numbe"75: p"ima" <e1studPno
numbe"75: "efe"ences student7stud:no::K
S0LIdsec membe"s!ipK
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL3
MEMPNO NO9 NULL NUMBE@75:
S9UDPNO NUMBE@75:
K.Ravi 28
DBMS Lab Manual
S0LIinse"t into membe"s!ip $alues7[memPno1[studPno:K
Ente" $alue fo" memPno:5**=
Ente" $alue fo" studPno:5&=
old &:inse"t into membe"s!ip $alues7[memPno1[studPno:
neA &:inse"t into membe"s!ip $alues75**=15&=:
inse"t into membe"s!ip $alues75**=15&=:
Y
Errors 1bser4e30
E@@O@ at line &:
O@A>=));&:inte+"it const"aint7CA@ISC3SJSPC==)/)*:$iolated>p"ima" <e
not found
S0LIselect Y f"om membe"s!ipK
MEMPNO S9UDPNO
LLLLLLLLLLLLLLLLLLLLLLLLLLL33
5**= 5&(
5**& 5=4
5**) 5&4
5**( 5(*
5*** 5)*
S0LIc"eate table boo<7boo<Pno numbe"75: p"ima" <e1boo<Pname
$a"c!a")7)=:1aut!o" $a"c!a")7)::K
S0LIdesc boo<K
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
BOO2PNO NO9 NULL NUMBE@75:
BOO2PNAME %A@CCA@)7)=:
AU9CO@ %A@CCA@)7)=:
S0LIinse"t into boo< $alues7[boo<Pno1F[boo<PnameF1F[aut!o"F:K
S0LIselect Y f"om boo<K
BOO2PNO BOO2PNAME AU9CO@
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
;&)( DBMS @ama 2"is!na
)(*) 8A%A @obett Ail<ins
*5)( Hea"less tales Alf"ed
4/)( m ambition Ca"is!
/4)& Ca"" ,otte" 82 @oAlin+
K.Ravi 29
DBMS Lab Manual
S0LIc"eate table lssP"ec7issPno numbe" p"ima" <e1issPdate date1memPno
numbe"75: "efe"ences membe"s!ip7memPno:1boo<Pno numbe"75:
"efe"ences boo<7boo<Pno::K
S0LIdesc issP"ecK
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
ISSPNO NO9 NULL NUMBE@
ISSPDA9E DA9E
MEMPNO NUMBE@75:
BOO2PNO NUMBE@75:
S0LIselect Y f"om issP"ecK
ISSPNO ISSPDA9E MEMPNO BOO2PNO
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
*( =5>8AN>=. 5**( *5)(
4& )4>DEC>=5 5**& 4/)(
)) =4>DEC>=5 5**= /4)&
5( =/>8AN>=. 5**) ;&)(
(5 =.>8AN>=. 5*** )(*)
c$ List all t!e student names Ait! t!ei" membe"s!ip numbe"s
S0LI select s3studname1 m3memno f"om student s1 membe"s!ip m A!e"e
m3studnoRs3studnoK
S9UDNAME MEMNO
>>>>>>>>>>>>>>>>>>>>>
ab!i'eet &==&
a"un &==)
a"$ind &==(
as!is! &==*
as!Ain &==5
3$ List all t!e issues fo" t!e cu""ent date Ait! student and Boo< names
S0LI select i3issno1 s3studname1 b3boo<name f"om issP"ec I1 membe"s!ip
m1 student s1 boo< b
) A!e"e i3memnoRm3memno and m3studnoRs3studno and
i3issdateRtoPc!a"7ssdate:K
ISSNO S9UDNAME BOO2NAME
>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>>>>
K.Ravi 30
DBMS Lab Manual
&( a"$ind ,[S
e$ List t!e details of students A!o bo""oAed boo< A!ose aut!o" is
C8DA9E
S0LI select Y f"om student A!e"e studno in7select studno f"om membe"s!ip
A!e"e memno in
) 7select memno f"om issP"ec A!e"e boo<no in7select boo<no f"om boo<
A!e"e aut!o"RFC8DA9EF:::K
S9UDNO S9UDNAME
>>>>>>>>>> >>>>>>>>>>>>>
5=5 as!Ain
%$ Gi$e a count of !oA man boo<s !a$e been bou+!t b eac! student
S0LI select s3studno1 count7i3boo<no: f"om student s3membe"s!ip m1 boo<
b1 ) issP"ec I A!e"e s3studnoRm3studno and b3boo<noRi3boo<no +"oup b
s3studnoK
S9UDNO COUN97I3BOO2NO:
>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>
5=& 5
5=) 5
5=( 5
5=* 5
5=5 5
g$ Gi$e a list of boo<s ta<en b student Ait! studPno as 5
S0LI select boo<name f"om boo< A!e"e boo<no in 7select boo<no f"om
issP"ec A!e"e
) memno in7select memno f"om membe"s!ip A!e"e
( studno in7select studno f"om student A!e"e studnoR5:::K
BOO2NAME
>>>>>>>>>>>>>
N9
h$ List t!e boo< details A!ic! a"e issued as of toda
S0LI delete f"om boo< A!e"e boo<no in7select boo<no f"om issP"ec A!e"e
issdateRtoPc!a"7ssdate::K
K.Ravi 31
DBMS Lab Manual
delete f"om boo< A!e"e boo<no in 7select boo<no f"om issP"ec A!e"e
issdateRtoPc!a"7ssdate::
Errors 1bser4e30
E@@O@ at line &:
O@A>=));): inte+"it const"aint 7SCO993SJSPC==4*=: $iolated - c!ild "eco"d
found
i$ C"eate a $ieA A!ic! lists out t!e issPno1 iss Pdate1 studPname1 boo<
name
H$ C"eate a $ieA A!ic! lists t!e dail issues>date Aise fo" t!e last one
Aee<
8i4a@8ice0
%. Describe the three le!els of data abstraction?
9!e a"e t!"ee le$els of abst"action:
$hysical le!el& 9!e loAest le$el of abst"action desc"ibes !oA data a"e
sto"ed3
'ogical le!el& 9!e ne6t !i+!e" le$el of abst"action1 desc"ibes A!at data
a"e sto"ed in database and A!at "elations!ip amon+ t!ose data3
(ie) le!el& 9!e !i+!est le$el of abst"action desc"ibes onl pa"t of enti"e
database3
2. Define the *integrity rules*
9!e"e a"e tAo Inte+"it "ules3
+ntity ,ntegrity& States t!at S,"ima" <e cannot !a$e NULL
$alueT
-eferential ,ntegrity& States t!at SHo"ei+n 2e can be eit!e" a
NULL $alue o" s!ould be ,"ima" 2e $alue of ot!e" "elation3
3. What is e.tension and intension?
+.tension >
It is t!e numbe" of tuples p"esent in a table at an instance3 9!is
is time dependent3
,ntension >
K.Ravi 32
DBMS Lab Manual
It is a constant $alue t!at +i$es t!e name1 st"uctu"e of table and
t!e const"aints laid on it3
4. What is System -? What are its t)o ma/or subsystems?
Sstem @ Aas desi+ned and de$eloped o$e" a pe"iod of &;/*>/; at
IBM San 8ose @esea"c! Cente"3 It is a p"ototpe and its pu"pose Aas to
demonst"ate t!at it is possible to build a @elational Sstem t!at can be used
in a "eal life en$i"onment to sol$e "eal life p"oblems1 Ait! pe"fo"mance at
least compa"able to t!at of e6istin+ sstem3
Its tAo subsstems a"e
@esea"c! Sto"a+e
Sstem @elational Data Sstem3
5. 0o) is the data structure of System - different from the relational
structure?
Unli<e @elational sstems in Sstem @
Domains a"e not suppo"ted
Enfo"cement of candidate <e uni?ueness is optional
Enfo"cement of entit inte+"it is optional
@efe"ential inte+"it is not enfo"ced
". What is Data ,ndependence?
Data independence means t!at St!e application is independent of t!e
sto"a+e st"uctu"e and access st"ate+ of dataT3 In ot!e" Ao"ds1 9!e abilit to
modif t!e sc!ema definition in one le$el s!ould not affect t!e sc!ema
definition in t!e ne6t !i+!e" le$el3
9Ao tpes of Data Independence:
,!sical Data Independence: Modification in p!sical le$el s!ould
not affect t!e lo+ical le$el3
Lo+ical Data Independence: Modification in lo+ical le$el s!ould
affect t!e $ieA le$el3
123+& 'ogical Data ,ndependence is more difficult to achie!e
4. What is a !ie)? 0o) it is related to data independence?
A $ieA ma be t!ou+!t of as a $i"tual table1 t!at is1 a table t!at does
not "eall e6ist in its oAn "i+!t but is instead de"i$ed f"om one o" mo"e
unde"lin+ base table3 In ot!e" Ao"ds1 t!e"e is no sto"ed file t!at di"ect
"ep"esents t!e $ieA instead a definition of $ieA is sto"ed in data dictiona"3
G"oAt! and "est"uctu"in+ of base tables is not "eflected in $ieAs3 9!us
t!e $ieA can insulate use"s f"om t!e effects of "est"uctu"in+ and +"oAt! in
t!e database3 Cence accounts fo" lo+ical data independence3
K.Ravi 33
DBMS Lab Manual
B" Database 'chema %or a Emplo)ee@pa) scenario
emploee7empAi3 0 integer 1 empPname: st"in+:
depa"tment73eptAi30 integer1 deptPname:st"in+:
padetails7empAi3 0 integer1 3eptAi30 integer1 basic: inte+e"1 deductions:
inte+e"1 additions: inte+e"1 DO8: date:
pa"oll!empAi3 0 integer1 paPdate: date:
For the abo4e schema, per%orm the %ollo9ingG
a: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b: Inse"t a"ound &= "eco"ds in eac! of t!e tables
c: List t!e emploee details depa"tment Aise
d: List all t!e emploee names A!o 'oined afte" pa"ticula" date
e: List t!e details of emploees A!ose basic sala" is betAeen &=1===
and )=1===
f: Gi$e a count of !oA man emploees a"e Ao"<in+ in eac! depa"tment
+: Gi$e a names of t!e emploees A!ose netsala"I&=1===
!: List t!e details fo" an emploeePidR5
i: C"eate a $ieA A!ic! lists out t!e empPname1 depa"tment1 basic1
dedeuctions1 netsala"
': C"eate a $ieA A!ic! lists t!e empPname and !is netsala"
K.Ravi 34
DBMS Lab Manual
AI(0 C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
Inse"t a"ound &= "eco"ds in eac! of t!e tables
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle

C"eate table emploee7empPid numbe"75: p"ima" <e1empPname
$a"c!a")7)5::K
S0LIdesc emploeeK
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
EM,PID NO9 NULL NUMBE@75:
EM,PNAME %A@CCA@)7)5:
8ali3 /est Data0
S0LIinse"t into emploee $alues7[empPid1F[empPnameF:K
S0LIselect Y f"om emploeeK
EM,PID EM,PNAME
LLLLLLLLLLLLLLLLLLLLLL3
&= @obe"t
)& Coult!a"d
(= He"nando Alonso
(; 2a"ti<ean
4/ 2immi
S0LIc"eate table depa"tment7deptPid numbe"75: p"ima" <e1deptPname
$a"c!a")7)=::K
S0LIdesc depa"tmentK
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
DE,9PID NO9 NULL NUMBE@75:
DE,9PNAME %A@CCA@)7)=:
S0LIinse"t into depa"tment $alues7[deptPid1F[deptPnameF:K
K.Ravi 35
DBMS Lab Manual
S0LIselect Y f"om depa"tmentK
DE,9PID DE,9PNAME
LLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
&== sales
&=& accounts
&=) administ"ation
&=( p"oduction
&=* supe"$iso"
S0LIc"eate table padetails7empPid numbe"75: "efe"ences
emploee7empPid:1deptPid numbe"75: "ee"ences depa"tment7deptPid:1basic
numbe"7/1):1deductions numbe"751):1additions numbe"751):1do' date:K
S0LIdesc padetailsK
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
EM,PID NUMBE@75:
DE,9PID NUMBE@75:
BASIC NUMBE@7/1):
DEDUC9IONS NUMBE@751):
ADDI9IONS NUMBE@751):
DO8 DA9E
Di%%erent Data 'ets0
S0LIinse"t into padeatils $alues7[empPid1[deptPid1
[basic1[deductions1[additions1[do':K
S0LIselect Y f"om padeatilsK
EM,PID DE,9PID BASIC DEDUC9IONS ADDI9IONS DO8
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
&= &=& )5=)(3&) *(3=; /&3)( =4>8AN>;(
)& &== &=5==3); )(3;4 *=3; =&>8AN>=.
(= &=) .5==35 (=35* &5 =.>8UL>;/
(; &=( ;/==3*5 ()3/4 .53=; =4>AUG>=(
4/ &=* &5=== ;/3.. &5*34 )*>SE,>=*
S0LIc"eate table pa"oll7empPid numbe"75:"efe"ences
emploee7empPid:1paPdate date:K
S0LIdesc pa"ollK
Name NullZ 9pe
K.Ravi 36
DBMS Lab Manual
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
EM,PID NUMBE@75:
,AJPDA9E DA9E
S0LIinse"t into pa"oll $alues7[empPid1F[dateF:K
S0LIselect Y f"om pa"ollK
EM,PID ,AJPDA9E
LLLLLLLLLLLLLLLLLLLLLL3
&= (&>8AN>=.
)& =(>HEB>=.
(= &5>8AN>=.
(; )/>8AN>=.
4/ =*>HEB>=.
c$ List t!e emploee details depa"tment Aise
S0LIselect empid1deptid f"om padetK
EM,ID DE,9ID
LLLLLLLLLL
*=& 5==
*=) )==
*=( .==
*=* *==
*=5 &)==
d: List all t!e emploee names A!o 'oined afte" pa"ticula" date
S0LIselect e1empname f"om emploee e1padet p A!e"e e3empidRp3empid
and p3do'IRF=5>ma">=.FK
EM,NAME
LLLLLLL
A%INASC
NI9IN
,CALGUN
e: List t!e details of emploees A!ose basic sala" is betAeen &=1=== and
)=1===
s?LI Select empid1empname f"om emploee A!e"e sala" betAeen &====
and )====K
EM,ID EM,NAME
K.Ravi 37
DBMS Lab Manual
LLLLLLLLLLL3
*=) A2CILA
*=( aaaaaaaa
EM,ID EM,NAME
LLLLLLLLLLL3
A2CILA
%: Gi$e a count of !oA man emploees a"e Ao"<in+ in eac! depa"tment
S0LIselect count7empid:1deptid f"om padet +"oup b deptidK
COUN9 7EM,ID: DE,9ID
LLLLLLLLLLLLLLLLLLLLL
& )==
& *==
& 5==
& .==
& &)==
g: Gi$e a names of t!e emploees A!ose netsala"I&=1===
S0LI select empname f"om emploee A!e"e empid in7select empid f"om
padet A!e"e basic>deductionI&====:K
EM,NAME
LLLLLL
A%INASC
A2CILA
CA@ISC
NI9IN
,CALGUN
!: List t!e details fo" an emploeePidR5
S0LI select Y f"om emploee A!e"e empidR5K
EM,ID EM,NAME
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
5 Coult!a"d
K.Ravi 38
DBMS Lab Manual
i: C"eate a $ieA A!ic! lists out t!e empPname1 depa"tment1 basic1
dedeuctions1 netsala"
': C"eate a $ieA A!ic! lists t!e empPname and !is netsala"
8i4a@8ice0
%3. What is Data Model?
A collection of conceptual tools fo" desc"ibin+ data1 data "elations!ips
data semantics and const"aints3
%4. What is +5- model?
9!is data model is based on "eal Ao"ld t!at consists of basic ob'ects
called entities and of "elations!ip amon+ t!ese ob'ects3 Entities a"e
desc"ibed in a database b a set of att"ibutes3
%5. What is 2b/ect 2riented model?
9!is model is based on collection of ob'ects3 An ob'ect contains $alues
sto"ed in instance $a"iables Ait! in t!e ob'ect3 An ob'ect also contains
bodies of code t!at ope"ate on t!e ob'ect3 9!ese bodies of code a"e called
met!ods3 Ob'ects t!at contain same tpes of $alues and t!e same met!ods
a"e +"ouped to+et!e" into classes3
%". What is an +ntity?
It is a \t!in+\ in t!e "eal Ao"ld Ait! an independent e6istence3
%4. What is an +ntity type?
It is a collection 7set: of entities t!at !a$e same att"ibutes3
%6. What is an +ntity set?
It is a collection of all entities of pa"ticula" entit tpe in t!e database3
K.Ravi 39
DBMS Lab Manual
C" Database 'chema %or a 8i3eo *ibrar) scenario
Custome"7custPno: inte+e"1custPname: st"in+:
Membe"s!ip7(emAno0 integer1 c&stAno0 integer:
Cassette7cassAno0integer1 cassPname:st"in+1 Lan+ua+e: St"in+:
IssP"ec!issAno0 integer1 issPdate: date1 memAno0 integer1 cassAno0
integer:
For the abo4e schema, per%orm the %ollo9ingG
a: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b: Inse"t a"ound &= "eco"ds in eac! of t!e tables
c: List all t!e custome" names Ait! t!ei" membe"s!ip numbe"s
d: List all t!e issues fo" t!e cu""ent date Ait! t!e custome" names and
cassette names
e: List t!e details of t!e custome" A!o !as bo""oAed t!e cassette A!ose
title is S 9!e Le+endT
f: Gi$e a count of !oA man cassettes !a$e been bo""oAed b eac!
custome"
+: Gi$e a list of boo< A!ic! !as been ta<en b t!e student Ait! memPno
as 5
!: List t!e cassettes issues fo" toda
i: C"eate a $ieA A!ic! lists outs t!e issPno1 issPdate1 custPname1
cassPname
': C"eate a $ieA A!ic! lists issues>date Aise fo" t!e last one Aee<
K.Ravi 40
DBMS Lab Manual
AI(0 C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
Inse"t a"ound &= "eco"ds in eac! of t!e tables
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle
S0LIc"eate table custome"7custPno numbe"75: p"ima" <e1custPname
$a"c!a")7)=::K
S0LIdesc custome"K
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
CUS9PNO NO9 NULL NUMBE@75:
CUS9PNAME %A@CCA@)7)=:
8ali3 /est Data0
S0LIinse"t into custome" $alues7[custPno1F[custPnameF:K
S0LIselect Y f"om custome"K
CUS9PNO CUS9PNAME
LLLLLLLLLLLLLLLLLLLLLLLL3
5= scott
5& pande
5) $a"s!ne
5( naidu
5* b!imb"a
S0LIc"eate table membe"s!ip7memPno numbe"75: p"ima" <e1custPno
numbe"75: "efe"ences custome"7custPno::K
S0LIdsec membe"s!ipK
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL333
MEMPNO NO9 NULL NUMBE@75:
CUS9PNO NUMBE@75:
K.Ravi 41
DBMS Lab Manual
S0LIinse"t into mems!ip $alues7[memPno1[custPno:K
S0LIselect Y f"om mems!ipK
MEMPNO CUS9PNO
LLLLLLLLLLLLLLLLLLL
;)= 5=
;4& 5&
4;/ 5)
4)= 5(
;)4 5*

S0LIc"eate table cassette7cassPno numbe"75: p"ima" <e1
CassPname $a"c!a")7&5:1lan+ua+e $a"c!a")7&5::K
S0LIdesc cassetteK
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL33
CASSPNO NO9 NULL NUMBE@75:
CASSPNAME %A@CCA@)7&5:
LANGUAGE %A@CCA@)7&5:
S0LIinse"t into cassette $alues7[cassPno1F[cassPnameF1F[lan+ua+eF:K
S0LIselect Y f"om cassetteK
CASSPNO CASSPNAME LANGUAGE
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
& ta+o"e telu+u
) t!e lion <in+ En+lis!
( annian tamil
* ind"a telu+u
5 lo"d of "in+s En+lis!
S0LIc"eate table issuP"ec7issPno numbe"75: p"ima" <e1issPdate
date1memPno numbe"75:"efe"ences mems!ip7memPno:1cassPno numbe"75:
"efe"ences cassette7cassPno::K
S0LIdesc issuP"ecK
Name NullZ 9pe
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL333
ISSPNO NO9 NULL NUMBE@75:
ISSPDA9E DA9E
MEMPNO NUMBE@75:
K.Ravi 42
DBMS Lab Manual
CASSPNO NUMBE@75:
S0LIselect Y f"om issuP"ecK
ISSPNO ISSPDA9E MEMPNO CASSPNO
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
)) =/>8AN>=. ;)= &
)( &=>8AN>== ;4& )
). &=>8AN>=. 4;/ 5
( =&>8AN>=. 4)= *
(* (&>DEC>=5 ;)4 (
c: List all t!e custome" names Ait! t!ei" membe"s!ip numbe"s
S0LIselect c3custname1m3memno f"om custome"& c1membe"s!ip& m
A!e"e c3custnoRm3custnoK
CUS9NAME MEMNO
LLLLLL33 LLLLLL33
NI2CIL 5&
%I%E2 5)
SC@A%AN 54
%AMSI 5/
SCI%A 5.
d: List all t!e issues fo" t!e cu""ent date Ait! t!e custome" names and
cassette names
S0LIselect i3issno1c3custname1cc3cassettename f"om custome"&
c1membe"s!ip& m1cassette cc1iss"ec& I A!e"e
i3issdateRtoPc!a"7ssdate: and c3custnoRm3custno and
i3cassnoRcc3cassno and i3memnoRm3memnoK
1&t#&t0
no "oAs selected3
e: List t!e details of t!e custome" A!o !as bo""oAed t!e cassette A!ose
title is S 9!e Le+endT
f: Gi$e a count of !oA man cassettes !a$e been bo""oAed b eac!
custome"
+: Gi$e a list of boo< A!ic! !as been ta<en b t!e student Ait! memPno
as 5
!: List t!e cassettes issues fo" toda
K.Ravi 43
DBMS Lab Manual
i: C"eate a $ieA A!ic! lists outs t!e issPno1 issPdate1 custPname1
cassPname
': C"eate a $ieA A!ic! lists issues>date Aise fo" t!e last one Aee<
8i4a@8ice0
%7. What is an +.tension of entity type?
9!e collections of entities of a pa"ticula" entit tpe a"e +"ouped
to+et!e" into an entit set3
28. What is Wea9 +ntity set?
An entit set ma not !a$e sufficient att"ibutes to fo"m a p"ima" <e1
and its p"ima" <e comp"omises of its pa"tial <e and p"ima" <e of its
pa"ent entit1 t!en it is said to be Dea< Entit set3
2%. What is an attribute?
It is a pa"ticula" p"ope"t1 A!ic! desc"ibes t!e entit3
22. What is a -elation Schema and a -elation?
A "elation Sc!ema denoted b @7A&1 A)1 L1 An: is made up of t!e
"elation name @ and t!e list of att"ibutes Ai t!at it contains3 A "elation is
defined as a set of tuples3 Let " be t!e "elation A!ic! contains set tuples 7t&1
t)1 t(1 3331 tn:3 Eac! tuple is an o"de"ed list of n>$alues tR7$&1$)1 3331 $n:3
23. What is degree of a -elation?
It is t!e numbe" of att"ibute of its "elation sc!ema3
24. What is -elationship?
It is an association amon+ tAo o" mo"e entities3
25. What is -elationship set?
9!e collection 7o" set: of simila" "elations!ips3
K.Ravi 44
DBMS Lab Manual
5"Database 'chema %or a st&3ent@*ab scenario
Student7st&3Ano0 integer1 studPname: st"in+1 class0 string:
Class7class0 string, 3escrip0 string:
Lab7machAno0 integer1 LabPno: inte+e"1 desc"iption: St"in+:
Allotment7't&3Ano0 Integer, machAno0 integer, 3a)o% 9ee=0 string$
For the abo4e schema, per%orm the %ollo9ingG
a: C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
b: Inse"t a"ound &= "eco"ds in eac! of t!e tables
c: List all t!e mac!ine allotments Ait! t!e student names1 lab and
mac!ine numbe"s
d: List t!e total numbe" of lab allotments da Aise
e: Gi$e a count of !oA man mac!ines !a$e been allocated to t!e MCSI9F
class
f: Gi$e a mac!ine allotment etails of t!e studPno 5 Ait! !is pe"sonal and
class details
+: Count fo" !oA man mac!ines !a$e been allocatedin *abAno 1 fo"
t!e da of t!e Aee< as SMondaT
!: CoA man students class Aise !a$e allocated mac!ines in t!e labs
i: C"eate a $ieA A!ic! lists out t!e studPno1 studPname1 mac!Pno1
labPno1 daofAee<
': C"eate a $ieA A!ic! lists t!e mac!ine allotment details fo" S9!u"sdaT
K.Ravi 45
DBMS Lab Manual
AI(0 C"eate t!e tables Ait! t!e app"op"iate inte+"it const"aints
Inse"t a"ound &= "eco"ds in eac! of t!e tables
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle
S0LIc"eate table stu7studPno numbe"75: p"ima" <e1studPnam
$a"c!a")7)=:1class $a"c!a")7)=::K
S0LI desc stuK
Name nullZ 9pe
S9UDPNO NO9 NULL NUMBE@75:
S9UDPNAM %A@CCA@)7)=:
CLASS %A@CCA@)7)=:
8ali3 Data 'ets0
S0LI inse"t into stu $alues7[studPno1F[studPnamF1F[classF:K
S0LI select Y f"om stuK
S9UDPNO S9UDPNAM CLASS
(; LEON CSE
(* %I2AS CSI9
&4 MA9CED ECE
4 CANSEN MECC
)* ALEEIS EEE
S0LI C"eate table class 7class $a"c!a")7)=:1 desc"ipt $a"c!a")7&=::K
S0LI Desc"ibe classK
Name null tpe
CLASS %A@CCA@)7&=:
DESC@I,9 %A@CCA@)7)=:
S0LI c"eate table lab7matc!Pno numbe"75:1 labPno numbe"75:1 desc"iption
$a"c!a")7)=::K
K.Ravi 46
DBMS Lab Manual
S0LI desc labK
Name null tpe
MACCPNO NO9 NULL NUMBE@75:
LABPNO NUMBE@75:
DESC@I,9ION %A@CCA@)7)=:
S0LI inse"t into lab $alues7[mac!Pno1[labPno1F[desc"iptionF:K
S0LI select Y f"om labK
MA9CCPNO LABPNO DESC@I,9ION
>>>>>>>>>>>>>>> >>>>>>>>> >>>>>>>>>>>>>>>>>>>>
)( / p!sics
/4 ) c!emist"
4/ & edc
&) &= cds
4 ( 'a$a lab
S0LI c"eate table allotment7studPno numbe"75: "efe"ences stu7studPno:1
matc!Pno numbe"75: "efe"ences lab7mac!Pno:1
DoAee< $a"c!a")7)=::K
S0LI desc allotmentK
Name NullZ 9pe
>>>>>>>>>>>>>> >>>>>>> >>>>>>>>>
S9UDPNO NUMBE@75:
MACCPNO NUMBE@75:
DODEE2 %A@CCA@)7)=:
S0LIselect Y f"om allotmentK
S9UDPNO MACCPNO DODEE2
>>>>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>
(; )( sat
(* 4/ mon
&4 /4 tue
4 &) Aed
)* &) t!u
K.Ravi 47
DBMS Lab Manual
c: List all t!e mac!ine allotments Ait! t!e student names1 lab and
mac!ine numbe"s
S0LIselect s3studname1l3mac!no f"om student& s1lab l1allotment a A!e"e
a3mac!noRl3mac!no and a3studnoRs3studnoK
S9UDNAME MACCNO
LLLLLLLLLLLLLLL33
ABCI8EE9 &
2ALJAN ))
ASCDIN (
A@2A *
A@%IND 5
d: List t!e total numbe" of lab allotments da Aise
S0LIselect l3mac!no1l3desc"ip1a3da f"om lab l1allotment a A!e"e
a3mac!noRl3mac!noK
MACCNO DESC@I, DAJ
LLLLLLLLLLLLLLLLLLLLLLLLLL
& UNIE MONDAJ
)) UNIE 9UESDAJ
( E, DEDNESDAJ
* DINDODS 9C@USDAJ
5 ME H@IDAJ
e: Gi$e a count of !oA man mac!ines !a$e been allocated to t!e MCSI9F
class
S0LIselect count7mac!no:f"om allotment A!e"e studno in7select studno
f"om student& A!e"e classRFCSI9F:K
COUN9 7MACCNO:
LLLLLLLL33
&
f: Gi$e a mac!ine allotment etails of t!e studPno 5 Ait! !is pe"sonal and
class details
S0LIselect a3studno1a3mac!no1s3studname1s3class f"om allotment
a1student& s A!e"e a3studnoRs3studno and a3studnoR5=(K
K.Ravi 48
DBMS Lab Manual

S9UDNO MACCNO S9UDNAME CLASS
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
5=( 5 A@%IND CSE
g) Count fo" !oA man mac!ines !a$e been allocatedin *abAno 1 fo"
t!e da of t!e Aee< as SMondaT
!: CoA man students class Aise !a$e allocated mac!ines in t!e labs
S0LIselect count7studno: Sallocated students in t!e labsT1class f"om
student& A!e"e studno in7select studno f"om allotment: +"oup b
classK
allocated students in t!e lab CLASS
LLLLLLLLLLLLLLLLLLLLLLLLLLLLL
) CSE
& ECE
& EEE
& I9
i: C"eate a $ieA A!ic! lists out t!e studPno1 studPname1 mac!Pno1
labPno1 daofAee<
': C"eate a $ieA A!ic! lists t!e mac!ine allotment details fo" S9!u"sdaT
8i4a@8ice0
2". What is -elationship type?
@elations!ip tpe defines a set of associations o" a "elations!ip set
amon+ a +i$en set of entit tpes3

24. What is degree of -elationship type?
It is t!e numbe" of entit tpe pa"ticipatin+3
25. What is DD' :Data Definition 'anguage;?
A data base sc!ema is specifies b a set of definitions e6p"essed b a
special lan+ua+e called DDL3
K.Ravi 49
DBMS Lab Manual
2". What is (D' :(ie) Definition 'anguage;?
It specifies use" $ieAs and t!ei" mappin+s to t!e conceptual sc!ema3
24. What is SD' :Storage Definition 'anguage;?
9!is lan+ua+e is to specif t!e inte"nal sc!ema3 9!is lan+ua+e ma
specif t!e mappin+ betAeen tAo sc!emas3
26. What is Data Storage 5 Definition 'anguage?
9!e sto"a+e st"uctu"es and access met!ods used b database sstem
a"e specified b a set of definition in a special tpe of DDL called data
sto"a+e>definition lan+ua+e3
27. What is DM' :Data Manipulation 'anguage;?
9!is lan+ua+e t!at enable use" to access o" manipulate data as
o"+anised b app"op"iate data model3
$rocedural DM' or 'o) le!el& DML "e?ui"es a use" to specif A!at data
a"e needed and !oA to +et t!ose data3
1on5$rocedural DM' or 0igh le!el& DML "e?ui"es a use" to specif A!at
data a"e needed Ait!out specifin+ !oA to +et t!ose data3
3%. What is DM' <ompiler?
It t"anslates DML statements in a ?ue" lan+ua+e into loA>le$el
inst"uction t!at t!e ?ue" e$aluation en+ine can unde"stand3
K.Ravi 50
DBMS Lab Manual
$" ;rite a program to %in3 largest n&mber %rom the
gi4en three n&mbers"
Aim0 9o find la"+est numbe" f"om t!e +i$en t!"ee numbe"s3
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
Algorithm0
Step &: Decla"e t!e $a"iable A1 B1 and C3
Step ): Sto"e t!e $alid data3
Step (: Compa"e $a"iable A Ait! B and A Ait! C
Step *: If t!e $alue sto"ed in $a"iable A is bi+1 it displas SA is Bi+T3 7IH
conditional statement s!ould be used:
Step 5: Compa"e $a"iable B Ait! C
Step .: If t!e $alue sto"ed in $a"iable B is bi+1 it displas SB is Bi+T3
Step /: ot!e" Aise it displas SC is Bi+T
Decla"e
A numbe"K
B numbe"K
C numbe"K
Be+in
A:R[aK
B:R[bK
C:R[cK
If a I b [[ aI c t!en
K.Ravi 51
DBMS Lab Manual
DbmsPoutput3putPline7M A is bi+ M:K
Else
If7 bIc [[ bI a : t!en
DbmsPoutput3putPline7M B is bi+ M:K
Else
DbmsPoutput3putPline7M C is bi+ M:K
End ifK
End ifK
EndK
8ali3 Data 'ets0
Ente" t!e $alue of a:
&
Ente" t!e $alue of b:
)
Ente" t!e $alue of c:
(
1U/#U/0
C is bi+
In4ali3 Data sets 0
Ente" t!e $alue of a:

Ente" t!e $alue of b:


6
Ente" t!e $alue of c:
a
1&tp&t0
In$alid data tpes3
8i4a@8ice0
K.Ravi 52
DBMS Lab Manual
(&3 D!at is ,l>S0L Z
,"ocedu"al Lan+ua+e St"uctu"ed 0ue" Lan+ua+e
32. What is =uery e!aluation engine?
It e6ecutes loA>le$el inst"uction +ene"ated b compile"3
33. What is DD' ,nterpreter?
It inte"p"ets DDL statements and "eco"d t!em in tables containin+
metadata3
34. What is -ecord5at5a5time?
9!e LoA le$el o" ,"ocedu"al DML can specif and "et"ie$e eac! "eco"d
f"om a set of "eco"ds3 9!is "et"ie$e of a "eco"d is said to be @eco"d>at>a>
time3
35. What is Set5at5a5time or Set5oriented?
9!e Ci+! le$el o" Non>p"ocedu"al DML can specif and "et"ie$e man
"eco"ds in a sin+le DML statement3 9!is "et"ie$e of a "eco"d is said to be Set>
at>a>time o" Set>o"iented3
3". What is -elational lgebra?
It is p"ocedu"al ?ue" lan+ua+e3 It consists of a set of ope"ations t!at
ta<e one o" tAo "elations as input and p"oduce a neA "elation3
34. What is -elational <alculus?
It is an applied p"edicate calculus specificall tailo"ed fo" "elational
databases p"oposed b E3H3 Codd3 E3+3 of lan+ua+es based on it a"e DSL
AL,CA1 0UEL3
K.Ravi 53
DBMS Lab Manual
,$" 'imple programs &sing loop, 9hile an3 %or iterati4e
control statement"
a$ 9o +ene"ate fi"st &= natu"al numbe"s usin+ loop, 9hile and %or3
AI(0 9o +ene"ate fi"st &= natu"al numbe"s usin+ loop1 A!ile and fo"3
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
Algorithm0
Step &: Decla"e t!e $a"iable I3
Step ): Sto"e t!e $alid data & in I3
Step (: Use *11# statement
Step *: Displa t!e fi"st $alue3
Step 5: Inc"ement t!e $alue of I b & $alue3
Step .: c!ec< t!e $alue up to &= no3 and "epeat t!e loop
Step /: If condition e6ceeds t!e +i$en $alue &=1 t!e loop Aill be
te"minated3
?J &sing loop statement J?
Decla"e
I numbe"K
Be+in
I:R&K
Loop
DbmsPoutput3putPline7I:K
I:RIG&K
K.Ravi 54
DBMS Lab Manual
E6it A!en II&=K
End loopK
EndK
Algorithm0 %or ;2I*E loop
Step &: Decla"e t!e $a"iable I3
Step ): Sto"e t!e $alid data & in I3
Step (: Use ;2I*E statement
Step *: C!ec< t!e $alue of I Ait! $alue &=3
Step 5: if t!e $alue of I "eac!ed to &= t!e loop Aill be te"minated
Step .: ot!e"Aise displa $alue of I
Step /: inc"ement t!e ne6t $alue of I usin+ IRIG&3
?J &sing 9hile J?
Decla"e
I numbe"K
Be+in
I:R&K
D!ile 7IVR&=:
loop
DbmsPoutput3putPline7I:K
I:RIG&K
End loopK
EndK
K.Ravi 55
DBMS Lab Manual
Algorithm0
Step &: Decla"e t!e $a"iable I3
Step ): Sto"e t!e $alue & in $a"3 I3
Step (: Use ForL *11# statement
Step *: Displa t!e fi"st $alue of I3
Step 5: Inc"ement t!e $alue of I b & $alue3
Step .: c!ec< t!e $alue up to &= no3 and "epeat t!e loop
Step /: if t!e loop e6ceeds t!e $alue &= t!en t!e loop Aill be
te"minated3
?J &sing %or loopJ?
Be+in
Ho" I in &33&=
loop
DbmsPoutput3putPline7I:K
End loopK
EndK
8ali3 /est Data:
1U/#U/
&
)
(
*
5
.
/
4
;
&=
K.Ravi 56
DBMS Lab Manual
8i4a@8ice0
36. 0o) does 3uple5oriented relational calculus differ from domain5
oriented relational calculus
9!e tuple>o"iented calculus uses a tuple $a"iables i3e31 $a"iable A!ose
onl pe"mitted $alues a"e tuples of t!at "elation3 E3+3 0UEL
9!e domain>o"iented calculus !as domain $a"iables i3e31 $a"iables t!at "an+e
o$e" t!e unde"lin+ domains instead of o$e" "elation3 E3+3 ILL1 DEDUCE3
37. What is normali>ation?
It is a p"ocess of analsin+ t!e +i$en "elation sc!emas based on t!ei"
Hunctional Dependencies 7HDs: and p"ima" <e to ac!ie$e t!e p"ope"ties
Minimi#in+ "edundanc
Minimi#in+ inse"tion1 deletion and update anomalies3
48. What is #unctional Dependency?
A Hunctional dependenc is denoted b E J betAeen tAo sets of
att"ibutes E and J t!at a"e subsets of @ specifies a const"aint on t!e possible
tuple t!at can fo"m a "elation state " of @3 9!e const"aint is fo" an tAo
tuples t& and t) in " if t&WEX R t)WEX t!en t!e !a$e t&WJX R t)WJX3 9!is
means t!e $alue of E component of a tuple uni?uel dete"mines t!e $alue of
component J3
4%. When is a functional dependency # said to be minimal?
E$e" dependenc in H !as a sin+le att"ibute fo" its "i+!t !and side3
De cannot "eplace an dependenc E A in H Ait! a dependenc J A
A!e"e J is a p"ope" subset of E and still !a$e a set of dependenc t!at is
e?ui$alent to H3
De cannot "emo$e an dependenc f"om H and still !a$e set of
dependenc t!at is e?ui$alent to H3
42. What is Multi!alued dependency?
Multi$alued dependenc denoted b E J specified on "elation
sc!ema @1 A!e"e E and J a"e bot! subsets of @1 specifies t!e folloAin+
const"aint on an "elation " of @: if tAo tuples t& and t) e6ist in " suc! t!at
t&WEX R t)WEX t!en t( and t* s!ould also e6ist in " Ait! t!e folloAin+
p"ope"ties
t(W6X R t*WEX R t&WEX R t)WEX
t(WJX R t&WJX and t*WJX R t)WJX
t(W]X R t)W]X and t*W]X R t&W]X
A!e"e W] R 7@>7E U J:: X
K.Ravi 57
DBMS Lab Manual

43. What is 'ossless /oin property?
It +ua"antees t!at t!e spu"ious tuple +ene"ation does not occu" Ait!
"espect to "elation sc!emas afte" decomposition3
K.Ravi 58
DBMS Lab Manual
D" #rogram to chec= 9hether gi4en n&mber is
Armstrong or not"
AI(0 to c!ec< A!et!e" +i$en numbe" is A"mst"on+ o" not3
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,l>S0L
Algorithm0
Step &: Decla"e t!e $a"iable N1 S1 D and DU,3
Step ): Sto"e t!e $alue in $a"3 N and $a"3 DU,33
Step (: c!ec< fo" t!e $alue of N1 A!ic! is not e?ual to =3
Step *: di$ide $alue sto"ed in N b &= and sto"e it $a"3 D3 7DRnU&=:3
Step 5: t!e "eminde" Aill be multipl ( times and sto"e it in %a"3 S3
Step .: 9!e coefficient Aill be calculated usin+ HLOO@ function3 And
sto"e it in $a"3 N3
Step /: "epeat t!e Steps (1 *1 51 and . till loop Aill be te"minated3
Step 4: C!ec< A!et!e" t!e sto"ed $alue and calculated $alues a"e same
Step ;: if bot! t!e $alues a"e same1 t!en displa S9!e +i$en numbe" is
A"mst"on+T
Step &=: Ot!e"Aise displa Sit is not A"mst"on+T and te"minate t!e
loop3
Decla"e
N numbe"K
S numbe"K
D numbe"K
Be+in
N:R[nK
S:R=K
D!ile7n^R=:
K.Ravi 59
DBMS Lab Manual
Loop
DRnU&=K
S:RsG7DYDYD:K
N:Rfloo"7n/&=:K
End loopK
If 7DU,RS: t!en
DBMSPoutput3putPline7Mnumbe" is a"mst"on+F:K
Else
DBMSPoutput3putPline7Mnumbe" is not a"mst"on+F:K
End ifK
EndK
/est 8ali3 Data 'et0
Ente" $alue of n
&5(
1U/#U/0
numbe" is A"mst"on+3
8i4a@8ice 0
44. What is 1 NF (Normal Form)?
!" #$%ain $& a''(ibu'" %u)' in*lu#" $nl+ a'$%i* ,)i%-l". in#ivi)ibl") valu").
45. What is Fully Functional dependency?
/' i) ba)"# $n *$n*"-' $& &ull &un*'i$nal #"-"n#"n*+. A &un*'i$nal #"-"n#"n*+ 0 1 i)
&ull &un*'i$nal #"-"n#"n*+ i& ("%$val $& an+ a''(ibu'" A &($% 0 %"an) '!a' '!" #"-"n#"n*+ #$")
n$' !$l# an+ %$(".
4". What is 2NF?
A ("la'i$n )*!"%a R i) in 223 i& i' i) in 123 an# "v"(+ n$n4-(i%" a''(ibu'" A in R i) &ull+
&un*'i$nall+ #"-"n#"n' $n -(i%a(+ 5"+.
44. What is 3NF?
K.Ravi 60
DBMS Lab Manual
A ("la'i$n )*!"%a R i) in 323 i& i' i) in 223 an# &$( "v"(+ 3D 0 A "i'!"( $& '!"
&$ll$6ing i) '(u"
0 i) a Su-"(45"+ $& R.
A i) a -(i%" a''(ibu'" $& R.
/n $'!"( 6$(#). i& "v"(+ n$n -(i%" a''(ibu'" i) n$n4'(an)i'iv"l+ #"-"n#"n' $n -(i%a(+ 5"+.
46. What is BCNF (Boyce-Codd Normal Form)?
A ("la'i$n )*!"%a R i) in BC23 i& i' i) in 323 an# )a'i)&i") an a##i'i$nal *$n)'(ain' '!a'
&$( "v"(+ 3D 0 A. 0 %u)' b" a *an#i#a'" 5"+.

47. What is 4NF?
A ("la'i$n )*!"%a R i) )ai# '$ b" in 423 i& &$( "v"(+ Mul'ivalu"# #"-"n#"n*+ 0
1 '!a' !$l#) $v"( R. $n" $& &$ll$6ing i) '(u"
0 i) )ub)"' $( "7ual '$ ,$() 01 8 R.
0 i) a )u-"( 5"+.
K.Ravi 61
DBMS Lab Manual
:" ;rite a program to generate all prime n&mbers
belo9 100"
AI(: to +ene"ate all p"ime numbe"s beloA &==3
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
Decla"e
I numbe"K
8 numbe"K
C numbe"K
Be+in
D!ile7iVR&==:
Loop
C:R=K
8:R&K
D!ile7'VRi:
Loop
If7floo"7iU':R=: t!en
C:R CG&K
End ifK
8:R'G&K
End loopK
K.Ravi 62
DBMS Lab Manual
If7cR): t!en
DbmsPoutput3putPline7i:K
End ifK
EndloopK
EndK
8ali3 /est Data
1U/#U/0
)
(
5
/
&&
3
3
;;
8i4a@8ice0
58. What is 5NF?
A R"la'i$n )*!"%a R i) )ai# '$ b" 523 i& &$( "v"(+ j$in #"-"n#"n*+ 9R1. R2. .... Rn:
'!a' !$l#) R. $n" '!" &$ll$6ing i) '(u"
Ri 8 R &$( )$%" i.
!" j$in #"-"n#"n*+ i) i%-li"# b+ '!" )"' $& 3D. $v"( R in 6!i*! '!" l"&' )i#" i) 5"+ $& R.
51 What is !omain-"ey Normal Form?
A ("la'i$n i) )ai# '$ b" in DK23 i& all *$n)'(ain') an# #"-"n#"n*i") '!a' )!$ul# !$l# $n
'!" '!" *$n)'(ain' *an b" "n&$(*"# b+ )i%-l+ "n&$(*ing '!" #$%ain *$n)'(ain' an# 5"+
*$n)'(ain' $n '!" ("la'i$n.

52 What are partial# alternate## arti$icial# compound and natural %ey?
&artial "ey'
/' i) a )"' $& a''(ibu'") '!a' *an uni7u"l+ i#"n'i&+ 6"a5 "n'i'i") an# '!a' a(" ("la'"# '$
)a%" $6n"( "n'i'+. /' i) )$%"'i%" *all"# a) Di)*(i%ina'$(.
K.Ravi 63
DBMS Lab Manual
(lternate "ey'
All Can#i#a'" K"+) ";*lu#ing '!" <(i%a(+ K"+ a(" 5n$6n a) Al'"(na'" K"+).
(rti$icial "ey=
/& n$ $bvi$u) 5"+. "i'!"( )'an# al$n" $( *$%-$un# i) availabl". '!"n '!" la)' (")$('
i) '$ )i%-l+ *("a'" a 5"+. b+ a))igning a uni7u" nu%b"( '$ "a*! ("*$(# $( $**u(("n*". !"n '!i) i)
5n$6n a) #"v"l$-ing an a('i&i*ial 5"+.
Compound "ey:
/& n$ )ingl" #a'a "l"%"n' uni7u"l+ i#"n'i&i") $**u(("n*") 6i'!in a *$n)'(u*'. '!"n
*$%bining %ul'i-l" "l"%"n') '$ *("a'" a uni7u" i#"n'i&i"( &$( '!" *$n)'(u*' i) 5n$6n a) *("a'ing a
*$%-$un# 5"+.
Natural "ey:
>!"n $n" $& '!" #a'a "l"%"n') )'$("# 6i'!in a *$n)'(u*' i) u'ili?"# a) '!" -(i%a(+
5"+. '!"n i' i) *all"# '!" na'u(al 5"+.
53 What is inde)in* and +hat are the di$$erent %inds o$ inde)in*?
/n#";ing i) a '"*!ni7u" &$( #"'"(%ining !$6 7ui*5l+ )-"*i&i* #a'a *an b" &$un#.
+-")=
Bina(+ )"a(*! )'+l" in#";ing
B4("" in#";ing
/nv"('"# li)' in#";ing
M"%$(+ (")i#"n' 'abl"
abl" in#";ing
K.Ravi 64
DBMS Lab Manual
10" ;rite a program to 3emonstrate the G1/1
statement"
AI(: to demonst"ate t!e GO9O statement
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
Decla"e
I numbe"K
Be+in
I:R&K
If7iIR=: t!en
GO9O !e"eK
Else
DbmsPoutput3putPline7 M I is ne+ati$eF:K
End ifK
VV!e"eII
DbmsPoutput3putPline7 M I is positi$eF:K
EndK
8ali3 /est Data
1U/#U/0
I is positi$e
K.Ravi 65
DBMS Lab Manual
8i4a@8ice0
54 What is system catalo* or catalo* relation? ,o+ is -etter %no+n as?
A RDBMS %ain'ain) a #")*(i-'i$n $& all '!" #a'a '!a' i' *$n'ain). in&$(%a'i$n ab$u' "v"(+
("la'i$n an# in#"; '!a' i' *$n'ain). !i) in&$(%a'i$n i) )'$("# in a *$ll"*'i$n $& ("la'i$n)
%ain'ain"# b+ '!" )+)'"% *all"# %"'a#a'a. /' i) al)$ *all"# #a'a #i*'i$na(+.
55 What is meant -y .uery optimi/ation?
!" -!a)" '!a' i#"n'i&i") an "&&i*i"n' ";"*u'i$n -lan &$( "valua'ing a 7u"(+ '!a' !a) '!"
l"a)' ")'i%a'"# *$)' i) ("&"(("# '$ a) 7u"(+ $-'i%i?a'i$n.
50 What is 1oin dependency and inclusion dependency?
2oin !ependency'
A @$in #"-"n#"n*+ i) g"n"(ali?a'i$n $& Mul'ivalu"# #"-"n#"n*+.A @D
9R1. R2. .... Rn: i) )ai# '$ !$l# $v"( a ("la'i$n R i& R1. R2. R3. .... Rn i) a l$))l"))4j$in
#"*$%-$)i'i$n $& R . !"(" i) n$ )"' $& )$un# an# *$%-l"'" in&"("n*" (ul") &$( @D.
3nclusion !ependency'
An /n*lu)i$n D"-"n#"n*+ i) a )'a'"%"n' $& '!" &$(% '!a' )$%" *$lu%n) $& a
("la'i$n a(" *$n'ain"# in $'!"( *$lu%n). A &$("ign 5"+ *$n)'(ain' i) an ";a%-l" $& in*lu)i$n
#"-"n#"n*+.
54 What is dura-ility in !B56?
An*" '!" DBMS in&$(%) '!" u)"( '!a' a '(an)a*'i$n !a) )u**"))&ull+ *$%-l"'"#. i') "&&"*')
)!$ul# -"()i)' "v"n i& '!" )+)'"% *(a)!") b"&$(" all i') *!ang") a(" ("&l"*'"# $n #i)5. !i)
-($-"('+ i) *all"# #u(abili'+.
57 What do you mean -y atomicity and a**re*ation?
(tomicity'
Bi'!"( all a*'i$n) a(" *a((i"# $u' $( n$n" a(". C)"() )!$ul# n$' !av" '$ 6$((+
ab$u' '!" "&&"*' $& in*$%-l"'" '(an)a*'i$n). DBMS "n)u(") '!i) b+ un#$ing '!" a*'i$n) $&
in*$%-l"'" '(an)a*'i$n).
(**re*ation'
A *$n*"-' 6!i*! i) u)"# '$ %$#"l a ("la'i$n)!i- b"'6""n a *$ll"*'i$n $& "n'i'i")
an# ("la'i$n)!i-). /' i) u)"# 6!"n 6" n""# '$ ";-(")) a ("la'i$n)!i- a%$ng ("la'i$n)!i-).
58 What is a &hantom !eadloc%?
/n #i)'(ibu'"# #"a#l$*5 #"'"*'i$n. '!" #"la+ in -($-aga'ing l$*al in&$(%a'i$n %ig!' *au)"
'!" #"a#l$*5 #"'"*'i$n alg$(i'!%) '$ i#"n'i&+ #"a#l$*5) '!a' #$ n$' ("all+ ";i)'. Su*! )i'ua'i$n)
a(" *all"# -!an'$% #"a#l$*5) an# '!"+ l"a# '$ unn"*"))a(+ ab$(').
09 What is a chec%point and When does it occur?
A C!"*5-$in' i) li5" a )na-)!$' $& '!" DBMS )'a'". B+ 'a5ing *!"*5-$in'). '!" DBMS
*an ("#u*" '!" a%$un' $& 6$(5 '$ b" #$n" #u(ing (")'a(' in '!" "v"n' $& )ub)"7u"n' *(a)!").
K.Ravi 66
DBMS Lab Manual
11" ;rite a program to 3emonstrate Kt)pe an3
Kro9t)pe attrib&tes
AI(: to demonst"ate Utpe and U"oAtpe att"ibutes
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
Decla"e
MPEmpno emp3empnoUtpeK
MPEname emp3enameUtpeK
MPEmp"oA empU"oAtpeK
No numbe"K
Be+in
No:R[noK
Select empno1ename into mPempno1mPename f"om emp A!e"e
empnoRnoK
If7S0lU"oAcountR&: t!en
DbmsPoutput3putPline7Mempno isF __ mPempno __ Mename is M __
mPename:K
Else
DbmsPoutput3putPline7 Me""o"F:K
End ifK
Select Y into mPemp"oA f"om emp A!e"e empnoRnoK
If7S0lU"oAcountR&: t!en
DbmsPoutput3putPline7Mempno isF __ mPemp"oA3empno __ Mename is M
__ mPemp"oA3ename:K
K.Ravi 67
DBMS Lab Manual
Else
DbmsPoutput3putPline7 Me""o"F:K
End ifK
EndK
8ali3 /est Data
Ente" t!e $alue fo" no:
//44
1U/#U/
empno is //44 ename is $ina s3
empno is //44 ename is $ina s3
8i4a@8ice
01 What are the di$$erent phases o$ transaction?
Di&&"("n' -!a)") a("
Anal+)i) -!a)"
R"#$ <!a)"
Cn#$ -!a)"
02 What do you mean -y $lat $ile data-ase?
/' i) a #a'aba)" in 6!i*! '!"(" a(" n$ -($g(a%) $( u)"( a**")) languag"). /' !a) n$ *($))4
&il" *a-abili'i") bu' i) u)"(4&(i"n#l+ an# -($vi#") u)"(4in'"(&a*" %anag"%"n'.
03 What is :transparent !B56:?
/' i) $n". 6!i*! 5""-) i') <!+)i*al S'(u*'u(" !i##"n &($% u)"(.
04 Brie$ theory o$ Net+or%# ,ierarchical schemas and their properties
2"'6$(5 )*!"%a u)") a g(a-! #a'a )'(u*'u(" '$ $(gani?" ("*$(#) ";a%-l" &$( )u*! a
#a'aba)" %anag"%"n' )+)'"% i) CCD 6!il" a !i"(a(*!i*al )*!"%a u)") a '("" #a'a )'(u*'u("
";a%-l" &$( )u*! a )+)'"% i) /MS.
05 What is a .uery?
A 7u"(+ 6i'! (")-"*' '$ DBMS ("la'") '$ u)"( *$%%an#) '!a' a(" u)"# '$ in'"(a*' 6i'! a
#a'a ba)". !" 7u"(+ languag" *an b" *la))i&i"# in'$ #a'a #"&ini'i$n languag" an# #a'a
%ani-ula'i$n languag".
K.Ravi 68
DBMS Lab Manual
00 What do you mean -y Correlated su-.uery?
Sub7u"(i"). $( n")'"# 7u"(i"). a(" u)"# '$ b(ing ba*5 a )"' $& ($6) '$ b" u)"# b+ '!"
-a("n' 7u"(+. D"-"n#ing $n !$6 '!" )ub7u"(+ i) 6(i''"n. i' *an b" ";"*u'"# $n*" &$( '!" -a("n'
7u"(+ $( i' *an b" ";"*u'"# $n*" &$( "a*! ($6 ("'u(n"# b+ '!" -a("n' 7u"(+. /& '!" )ub7u"(+ i)
";"*u'"# &$( "a*! ($6 $& '!" -a("n'. '!i) i) *all"# a correlated su-.uery.
A *$(("la'"# )ub7u"(+ *an b" "a)il+ i#"n'i&i"# i& i' *$n'ain) an+ ("&"("n*") '$ '!" -a("n'
)ub7u"(+ *$lu%n) in i') >EBRB *lau)". C$lu%n) &($% '!" )ub7u"(+ *ann$' b" ("&"("n*"#
an+6!"(" "l)" in '!" -a("n' 7u"(+. !" &$ll$6ing ";a%-l" #"%$n)'(a'") a n$n4*$(("la'"#
)ub7u"(+.
B.g. S"l"*' F 3($% CCS >!"(" G10H03H1990G /2 ,S"l"*' ADAB 3($% ARDBR >!"("
CCS.C2CM 8 ARDBR.C2CM)
04 What are the primiti;e operations common to all record mana*ement systems?
A##i'i$n. #"l"'i$n an# %$#i&i*a'i$n.
K.Ravi 69
DBMS Lab Manual
15" ;rite a program to 3emonstrate pre3e%ine3
e<ceptions
AI(: to demonst"ate p"edefined e6ceptions
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
Decla"e
A numbe"
B numbe"K
C numbe"K
Be+in
A:R[aK
B:R[bK
C:Ra/bK
DbmsPoutput3putPline7Mdi$ision is M __ C:K
E6ception
If 7]E@OPDI%IDE: t!en
DbmsPoutput3putPline7Mb could not be #e"oF:K
End ifK
EndK
8ali3 /est Data0
Ente" t!e $alue fo" a:
K.Ravi 70
DBMS Lab Manual
&=
Ente" t!e $alue fo" b:
=
1U/#U/0
b could not be #e"o
8i4a@8ice0
07 Name the -u$$er in +hich all the commands that are typed in are stored
Edit Bu&&"(
08 What are the unary operations in <elational (l*e-ra?
<RA@BC/A2 an# SBLBC/A2.
49 (re the resultin* relations o$ &<=!>C? and 2=3N operation the same?
2$.
&<=!>C?= C$n*a'"na'i$n $& "v"(+ ($6 in $n" ("la'i$n 6i'! "v"(+ ($6 in an$'!"(.
2=3N= C$n*a'"na'i$n $& ($6) &($% $n" ("la'i$n an# ("la'"# ($6) &($% an$'!"(.
41 What is <!B56 "@<N@A?
6$ i%-$('an' -i"*") $& RDBMS a(*!i'"*'u(" a(" '!" 5"(n"l. 6!i*! i) '!" )$&'6a(". an#
'!" #a'a #i*'i$na(+. 6!i*! *$n)i)') $& '!" )+)'"%4l"v"l #a'a )'(u*'u(") u)"# b+ '!" 5"(n"l '$
%anag" '!" #a'aba)"
1$u %ig!' '!in5 $& an RDBMS a) an $-"(a'ing )+)'"% ,$( )"' $& )ub)+)'"%)). #")ign"#
)-"*i&i*all+ &$( *$n'($lling #a'a a**"))I i') -(i%a(+ &un*'i$n) a(" )'$(ing. ("'(i"ving. an# )"*u(ing
#a'a. An RDBMS %ain'ain) i') $6n li)' $& au'!$(i?"# u)"() an# '!"i( a))$*ia'"# -(ivil"g")I
%anag") %"%$(+ *a*!") an# -agingI *$n'($l) l$*5ing &$( *$n*u(("n' (")$u(*" u)ag"I #i)-a'*!")
an# )*!"#ul") u)"( ("7u")')I an# %anag") )-a*" u)ag" 6i'!in i') 'abl"4)-a*" )'(u*'u(")
.
42 Name the su--systems o$ a <!B56
/HA. S"*u(i'+. Languag" <($*"))ing. <($*")) C$n'($l. S'$(ag" Manag"%"n'. L$gging an#
R"*$v"(+. Di)'(ibu'i$n C$n'($l. (an)a*'i$n C$n'($l. M"%$(+ Manag"%"n'. L$*5 Manag"%"n'
43 Which part o$ the <!B56 ta%es care o$ the data dictionary? ,o+
Da'a #i*'i$na(+ i) a )"' $& 'abl") an# #a'aba)" $bj"*') '!a' i) )'$("# in a )-"*ial a("a $& '!"
#a'aba)" an# %ain'ain"# ";*lu)iv"l+ b+ '!" 5"(n"l.
44 What is the 1o- o$ the in$ormation stored in data-dictionary?
!" in&$(%a'i$n in '!" #a'a #i*'i$na(+ vali#a'") '!" ";i)'"n*" $& '!" $bj"*'). -($vi#")
a**")) '$ '!"%. an# %a-) '!" a*'ual -!+)i*al )'$(ag" l$*a'i$n.
K.Ravi 71
DBMS Lab Manual
1C" ;rite a program to 3emonstrate &ser 3e%ine3
e<ceptions
AI(: to demonst"ate use" defined e6ceptions
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
Decla"e
A numbe"
B numbe"K
C numbe"K
Mdi$ideP#e"o EECE,9IONK
Be+in
A:R[aK
B:R[bK
If7BR=: t!en
@aise Mdi$ideP#e"oK
else
C:Ra/bK
DbmsPoutput3putPline7Mdi$ision is M __ C:K
End ifK
E6ception
If 7mdi$ideP#e"o: t!en
K.Ravi 72
DBMS Lab Manual
DbmsPoutput3putPline7Mb could not be #e"oF:K
End ifK
EndK
8ali3 /est Data0
Ente" t!e $alue fo" a:
&=
Ente" t!e $alue fo" b:
=
1U/#U/0
b could not be #e"o
8i4a@8ice0
45 Not only <!B56 ta%es care o$ locatin* data it also
#"'"(%in") an $-'i%al a**")) -a'! '$ )'$(" $( ("'(i"v" '!" #a'a
40 ,o+ do you communicate +ith an <!B56?
1$u *$%%uni*a'" 6i'! an RDBMS u)ing S'(u*'u("# Ju"(+ Languag" ,SJL)
44 !e$ine 6BA and state the di$$erences -et+een 6BA and other con;entional pro*rammin*
Aan*ua*es
SJL i) a n$n-($*"#u(al languag" '!a' i) #")ign"# )-"*i&i*all+ &$( #a'a a**")) $-"(a'i$n)
$n n$(%ali?"# ("la'i$nal #a'aba)" )'(u*'u("). !" -(i%a(+ #i&&"("n*" b"'6""n SJL an# $'!"(
*$nv"n'i$nal -($g(a%%ing languag") i) '!a' SJL )'a'"%"n') )-"*i&+ 6!a' #a'a $-"(a'i$n) )!$ul#
b" -"(&$(%"# (a'!"( '!an !$6 '$ -"(&$(% '!"%.
47 Name the three ma1or set o$ $iles on dis% that compose a data-ase in =racle
!"(" a(" '!("" %aj$( )"') $& &il") $n #i)5 '!a' *$%-$)" a #a'aba)". All '!" &il") a(" bina(+. !")" a("
Da'aba)" &il")
C$n'($l &il")
R"#$ l$g)
!" %$)' i%-$('an' $& '!")" a(" '!" #a'aba)" &il") 6!"(" '!" a*'ual #a'a (")i#"). !"
*$n'($l &il") an# '!" ("#$ l$g) )u--$(' '!" &un*'i$ning $& '!" a(*!i'"*'u(" i')"l&.
All '!("" )"') $& &il") %u)' b" -(")"n'. $-"n. an# availabl" '$ A(a*l" &$( an+ #a'a $n '!" #a'aba)" '$ b" u)"abl". >i'!$u' '!")" &il"). +$u
*ann$' a**")) '!" #a'aba)". an# '!" #a'aba)" a#%ini)'(a'$( %ig!' !av" '$ ("*$v"( )$%" $( all $& '!" #a'aba)" u)ing a ba*5u-. i& '!"(" i) $n".
K.Ravi 73
DBMS Lab Manual
48 What is an =racle 3nstance?
!" A(a*l" )+)'"% -($*"))"). al)$ 5n$6n a) A(a*l" ba*5g($un# -($*"))"). -($vi#"
&un*'i$n) &$( '!" u)"( -($*"))")K&un*'i$n) '!a' 6$ul# $'!"(6i)" b" #$n" b+ '!" u)"( -($*"))")
'!"%)"lv")
A(a*l" #a'aba)"46i#" )+)'"% %"%$(+ i) 5n$6n a) '!" SDA. '!" system *lo-al area $(
shared *lo-al area. !" #a'a an# *$n'($l )'(u*'u(") in '!" SDA a(" )!a("abl". an# all '!" A(a*l"
ba*5g($un# -($*"))") an# u)"( -($*"))") *an u)" '!"%.
!" *$%bina'i$n $& '!" SDA an# '!" A(a*l" ba*5g($un# -($*"))") i) 5n$6n a) an =racle
instance
79 What are the $our =racle system processes that must al+ays -e up and runnin* $or the
data-ase to -e usea-le
!" &$u( A(a*l" )+)'"% -($*"))") '!a' %u)' al6a+) b" u- an# (unning &$( '!" #a'aba)" '$
b" u)"abl" in*lu#" !BW< ,Da'aba)" >(i'"(). ACW< ,L$g >(i'"(). 65=N ,S+)'"% M$ni'$(). an#
&5=N ,<($*")) M$ni'$().
K.Ravi 74
DBMS Lab Manual
15" Create a C&rsor 9hich &p3ate the salaries o% an
Emplo)ee as %ollo9s"
&3 if salV&===t!en update t!e sala" to &5==3
)3 if salIR&=== and V)=== t!en update t!e sala" to )5==3
(3 if salIR)=== and VR(=== t!en update t!e sala" to *===3
And also count t!e no3of "eco"ds !a$e been updated3Y/
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
Decla"e
Cu"so" mPcu" is select empno1sal f"om empK
Eno emp3empnoUtpeK
Esal emp3salUtpeK
C numbe"K
Be+in
Open mPcu"K
C:R=K
Loop
Hetc! mPcu" into 6no16salK
If76salV&===: t!en
Update emp set salR(=== A!e"e empnoR6noK
C:RcG&K
K.Ravi 75
DBMS Lab Manual
Else if76salIR)===: and 6saV(===: t!en
Update emp set salR*=== A!e"e empnoR6noK
C:RcG&K
End ifK
End ifK
E6it A!en mPcu"UNO9HOUND K
End loopK
Close mPcu"K
DbmaPoutput3putPline7c__F"eco"ds !a$e been successfull updatedF:K
EndK
S?lINa3s?lK
"eco"ds !a$e been successfull updated
pl/s?l p"ocedu"e successfull completed3
8ali3 /est Data
Befo"e e6ecutin+ t!e cu"so"1 t!e "eco"ds in emp table as folloAs
S?lIselect Y f"om empK
1U/#U/0
EM,NO ENAME 8OB MG@ CI@EDA9E SAL COMMD E,9NO
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/(.; SMI9C CLE@2 /;=) &/>DEC>4= )=== )=
/*;; ALLEN SALESMAN /.;4 )=>HEB>4& &.== (== (=
/5)& DA@D SALESMAN /.;4 ))>HEB>4& &)5= 5== (=
EM,NO ENAME 8OB MG@ CI@EDA9E SAL COMM DE,9NO
K.Ravi 76
DBMS Lab Manual
>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/5.. 8ONES MANAGE@ /4(; =)>A,@>4& );/5 )=
/.5* MA@9IN SALESMAN /.;4 )4>SE,>4& &)5= &*== (=
/.;4 BLA2E MANAGE@ /4(; =&>MAJ>4& )45= (=
L
L3
L
&* "oAs selected3
8i4a@8ice0
71 What are data-ase $iles# control $iles and lo* $iles ,o+ many o$ these $iles should a
data-ase ha;e at least? Why?
!ata-ase Files
!" #a'aba)" &il") !$l# '!" a*'ual #a'a an# a(" '+-i*all+ '!" la(g")' in )i?".
D"-"n#ing $n '!"i( )i?"). '!" 'abl") ,an# $'!"( $bj"*')) &$( all '!" u)"( a**$un') *an g$ in $n"
#a'aba)" &il"Kbu' '!a'G) n$' an i#"al )i'ua'i$n b"*au)" i' #$") n$' %a5" '!" #a'aba)" )'(u*'u("
v"(+ &l";ibl" &$( *$n'($lling a**")) '$ )'$(ag" &$( #i&&"("n' u)"(). -u''ing '!" #a'aba)" $n #i&&"("n'
#i)5 #(iv"). $( ba*5ing u- an# (")'$(ing ju)' -a(' $& '!" #a'aba)".
You must have at least one database fle but usually, more than
one fles are used. In terms of accessing and using the data in the tables and
other objects, the number (or location) of the fles is immaterial.
!" #a'aba)" &il") a(" &i;"# in )i?" an# n"v"( g($6 bigg"( '!an '!" )i?" a' 6!i*!
'!"+ 6"(" *("a'"#
Control Files
!" *$n'($l &il") an# ("#$ l$g) )u--$(' '!" (")' $& '!" a(*!i'"*'u(". An+
#a'aba)" %u)' !av" a' l"a)' $n" *$n'($l &il". al'!$ug! +$u '+-i*all+ !av" %$(" '!an $n" '$
gua(# again)' l$)). !" *$n'($l &il" ("*$(#) '!" na%" $& '!" #a'aba)". '!" #a'" an# 'i%" i' 6a)
*("a'"#. '!" l$*a'i$n $& '!" #a'aba)" an# ("#$ l$g). an# '!" )+n*!($ni?a'i$n in&$(%a'i$n '$
"n)u(" '!a' all '!("" )"') $& &il") a(" al6a+) in )'"-. Bv"(+ 'i%" +$u a## a n"6 #a'aba)" $(
("#$ l$g &il" '$ '!" #a'aba)". '!" in&$(%a'i$n i) ("*$(#"# in '!" *$n'($l &il").
K.Ravi 77
DBMS Lab Manual
<edo Ao*s
An+ #a'aba)" %u)' !av" a' l"a)' '6$ ("#$ l$g). !")" a(" '!" j$u(nal) &$( '!"
#a'aba)"I '!" ("#$ l$g) ("*$(# all *!ang") '$ '!" u)"( $bj"*') $( )+)'"% $bj"*'). /& an+ '+-" $&
&ailu(" $**u(). '!" *!ang") ("*$(#"# in '!" ("#$ l$g) *an b" u)"# '$ b(ing '!" #a'aba)" '$ a
*$n)i)'"n' )'a'" 6i'!$u' l$)ing an+ *$%%i''"# '(an)a*'i$n). /n '!" *a)" $& n$n4#a'a l$)) &ailu(".
A(a*l" *an a--l+ '!" in&$(%a'i$n in '!" ("#$ l$g) au'$%a'i*all+ 6i'!$u' in'"(v"n'i$n &($% '!"
DBA.
!" ("#$ l$g &il") a(" &i;"# in )i?" an# n"v"( g($6 #+na%i*all+ &($% '!" )i?" a'
6!i*! '!"+ 6"(" *("a'"#.
72 What is <=W3!?
!" RA>/D i) a uni7u" #a'aba)"46i#" -!+)i*al a##(")) &$( "v"(+ ($6 $n "v"(+ 'abl".
An*" a))ign"# ,6!"n '!" ($6 i) &i()' in)"('"# in'$ '!" #a'aba)"). i' n"v"( *!ang") un'il '!" ($6 i)
#"l"'"# $( '!" 'abl" i) #($--"#.
!" RA>/D *$n)i)') $& '!" &$ll$6ing '!("" *$%-$n"n'). '!" *$%bina'i$n $& 6!i*!
uni7u"l+ i#"n'i&i") '!" -!+)i*al )'$(ag" l$*a'i$n $& '!" ($6.
A(a*l" #a'aba)" &il" nu%b"(. 6!i*! *$n'ain) '!" bl$*5 6i'! '!" ($6)
A(a*l" bl$*5 a##(")). 6!i*! *$n'ain) '!" ($6
!" ($6 6i'!in '!" bl$*5 ,b"*au)" "a*! bl$*5 *an !$l# %an+ ($6))
!" RA>/D i) u)"# in'"(nall+ in in#";") a) a 7ui*5 %"an) $& ("'(i"ving ($6) 6i'! a
-a('i*ula( 5"+ valu". A--li*a'i$n #"v"l$-"() al)$ u)" i' in SJL )'a'"%"n') a) a 7ui*5 6a+ '$
a**")) a ($6 $n*" '!"+ 5n$6 '!" RA>/D
73 What is =racle Bloc%? Can t+o =racle Bloc%s ha;e the same address?
A(a*l" L&$(%a')L '!" #a'aba)" &il") in'$ a nu%b"( $& A(a*l" bl$*5) 6!"n '!"+ a(" &i()'
*("a'"#K%a5ing i' "a)i"( &$( '!" RDBMS )$&'6a(" '$ %anag" '!" &il") an# "a)i"( '$ ("a# #a'a
in'$ '!" %"%$(+ a("a).
!" bl$*5 )i?" )!$ul# b" a %ul'i-l" $& '!" $-"(a'ing )+)'"% bl$*5 )i?". R"ga(#l")) $& '!"
bl$*5 )i?". '!" "n'i(" bl$*5 i) n$' availabl" &$( !$l#ing #a'aI A(a*l" 'a5") u- )$%" )-a*" '$
%anag" '!" *$n'"n') $& '!" bl$*5. !i) bl$*5 !"a#"( !a) a %ini%u% )i?". bu' i' *an g($6.
!")" A(a*l" bl$*5) a(" '!" )%all")' uni' $& )'$(ag". /n*("a)ing '!" A(a*l" bl$*5 )i?" *an
i%-($v" -"(&$(%an*". bu' i' )!$ul# b" #$n" $nl+ 6!"n '!" #a'aba)" i) &i()' *("a'"#.
Ba*! A(a*l" bl$*5 i) nu%b"("# )"7u"n'iall+ &$( "a*! #a'aba)" &il" )'a('ing a' 1. 6$
bl$*5) *an !av" '!" )a%" bl$*5 a##(")) i& '!"+ a(" in #i&&"("n' #a'aba)" &il").
74 What is data-ase ?ri**er?
A #a'aba)" '(igg"( i) a <LHSJL bl$*5 '!a' *an #"&in"# '$ au'$%a'i*all+ ";"*u'" &$( in)"('.
u-#a'". an# #"l"'" )'a'"%"n') again)' a 'abl". !" '(igg"( *an " #"&in"# '$ ";"*u'" $n*" &$( '!"
"n'i(" )'a'"%"n' $( $n*" &$( "v"(+ ($6 '!a' i) in)"('"#. u-#a'"#. $( #"l"'"#. 3$( an+ $n" 'abl".
'!"(" a(" '6"lv" "v"n') &$( 6!i*! +$u *an #"&in" #a'aba)" '(igg"(). A #a'aba)" '(igg"( *an *all
#a'aba)" -($*"#u(") '!a' a(" al)$ 6(i''"n in <LHSJL.
75 Name t+o utilities that =racle pro;ides# +hich are use $or -ac%up and reco;ery
Al$ng 6i'! '!" RDBMS )$&'6a(". A(a*l" -($vi#") '6$ u'ili'i") '!a' +$u *an u)" '$ ba*5
u- an# (")'$(" '!" #a'aba)". !")" u'ili'i") a(" @)port an# 3mport.
K.Ravi 78
DBMS Lab Manual
!" @)port utility #u%-) '!" #"&ini'i$n) an# #a'a &$( '!" )-"*i&i"# -a(' $& '!" #a'aba)" '$
an $-"(a'ing )+)'"% bina(+ &il". !" 3mport utility ("a#) '!" &il" -($#u*"# b+ an ";-$('. ("*("a'")
'!" #"&ini'i$n) $& $bj"*'). an# in)"(') '!" #a'a
/& B;-$(' an# /%-$(' a(" u)"# a) a %"an) $& ba*5ing u- an# ("*$v"(ing '!" #a'aba)". all
'!" *!ang") %a#" '$ '!" #a'aba)" *ann$' b" ("*$v"("# )in*" '!" ";-$(' 6a) -"(&$(%"#. !" b")'
+$u *an #$ i) ("*$v"( '!" #a'aba)" '$ '!" 'i%" 6!"n '!" ";-$(' 6a) la)' -"(&$(%"#.
K.Ravi 79
DBMS Lab Manual
1:" create a proce3&re 9hich generate all the prime
n&mbers belo9 the gi4en n&mber an3 co&nt the no"o%
prime n&mbers"
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
C"eate o" "eplace p"ocedu"e p"imePp"oc7n IN numbe"1tot OU9 numbe":
as
i numbe"K
c numbe"K
' numbe"K
Be+in
i:R&K
tot:R=K
A!ile7iVRn:
loop
':R&K
c:R=K
A!ile7'VRi:
loop
if7mod7I1':R=: t!en
K.Ravi 80
DBMS Lab Manual
c:RcG&K
end ifK
':R'G&K
end loopK
if7cR): t!en
dbmsPoutput3putPline7i:K
tot:RtotG&K
end ifK
i:RiG&K
end loopK
endK
/
S?lIp"ocedu"e c"eated3
decla"e
t numbe"K
be+in
p"imePp"oc7&=1t:K
dbmsPoutput3putPline7Mt!e total p"ime no 3a"eF__t:K
endK
8ali3 /est Data0
s?lIset se"$e"output on
1U/#U/
s?lI/
K.Ravi 81
DBMS Lab Manual
)
(
5
/
9!e total p"ime no3a"e *
,l/s?l p"ocedu"e successfull completed3
8i4a@8ice
70 Name t+o utilities that =racle pro;ides# +hich are use $or -ac%up and reco;ery
Al$ng 6i'! '!" RDBMS )$&'6a(". A(a*l" -($vi#") '6$ u'ili'i") '!a' +$u *an u)" '$ ba*5
u- an# (")'$(" '!" #a'aba)". !")" u'ili'i") a(" @)port an# 3mport.
!" @)port utility #u%-) '!" #"&ini'i$n) an# #a'a &$( '!" )-"*i&i"# -a(' $& '!" #a'aba)" '$
an $-"(a'ing )+)'"% bina(+ &il". !" 3mport utility ("a#) '!" &il" -($#u*"# b+ an ";-$('. ("*("a'")
'!" #"&ini'i$n) $& $bj"*'). an# in)"(') '!" #a'a
/& B;-$(' an# /%-$(' a(" u)"# a) a %"an) $& ba*5ing u- an# ("*$v"(ing '!" #a'aba)". all
'!" *!ang") %a#" '$ '!" #a'aba)" *ann$' b" ("*$v"("# )in*" '!" ";-$(' 6a) -"(&$(%"#. !" b")'
+$u *an #$ i) ("*$v"( '!" #a'aba)" '$ '!" 'i%" 6!"n '!" ";-$(' 6a) la)' -"(&$(%"#.
74 What are stored-procedures? (nd +hat are the ad;anta*es o$ usin* them
S'$("# -($*"#u(") a(" #a'aba)" $bj"*') '!a' -"(&$(% a u)"( #"&in"# $-"(a'i$n. A )'$("#
-($*"#u(" *an !av" a )"' $& *$%-$un# SJL )'a'"%"n'). A )'$("# -($*"#u(" ";"*u'") '!" SJL
*$%%an#) an# ("'u(n) '!" (")ul' '$ '!" *li"n'. S'$("# -($*"#u(") a(" u)"# '$ ("#u*" n"'6$(5
'(a&&i*.
77 ?a-les deri;ed $rom the @<!
a) A(" '$'all+ unn$(%ali)"#
b) A(" al6a+) in 123
*) Can b" &u('!"( #"n$(%ali)"#
#) Ma+ !av" %ul'i4valu"# a''(ibu'")
,b) A(" al6a+) in 123
78 6purious tuples may occur due to
i Bad normali/ation
ii ?heta 1oins
iii >pdatin* ta-les $rom 1oin
a) i M ii b) ii M iii
*) i M iii #) ii M iii
,a) i M iii b"*au)" '!"'a j$in) a(" j$in) %a#" $n 5"+) '!a' a(" n$' -(i%a(+ 5"+).
K.Ravi 82
DBMS Lab Manual
89 ( B C is a set o$ attri-utes ?he $unctional dependency is as $ollo+s
(B -D B
(C -D C
C -D B
a) i) in 123
b) i) in 223
*) i) in 323
#) i) in BC23
,a) i) in 123 )in*" ,AC)
N
8 9 A. B. C: !"n*" AC i) '!" -(i%a(+ 5"+. Sin*" C B
i) a 3D giv"n. 6!"(" n"i'!"( C i) a K"+ n$( B i) a -(i%" a''(ibu'". '!i) i' i) n$' in 323. 3u('!"( B
i) n$' &un*'i$nall+ #"-"n#"n' $n 5"+ AC '!u) i' i) n$' in 223. !u) '!" giv"n 3D) i) in 123.
K.Ravi 83
DBMS Lab Manual
1D" create a proce3&re 9hich &p3ates the salaries o%
an emplo)ees as %ollo9s"
&3if salV&=== t!en update t!e sal" to &5==3
)3if salIR&=== and VR)*== t!en update t!e sala" to )5==3Y/
2;?'; re>&irements0
,"ocesso" : AMD At!elon B &3./ GC
#
@AM : )5. MB
Ca"d Dis< : *= GB
SoftAa"e : O"acle1 ,lS0L
C"eate o" "eplace p"ocedu"e mp"oc as
Cu"so" mPcu" is select empno1sal f"om empK
Eno emp3empnoUtpeK
Esal emp3salUtpeK
C numbe"K
Be+in
Open mPcu"K
C:R=K
Loop
Hetc! mPcu" into 6no16salK
If76salV&===: t!en
Update emp set salR&5== A!e"e empnoR6noK
C:RcG&K
Else
Is76salIR&=== and 6salVR)*==: t!en
K.Ravi 84
DBMS Lab Manual
Update emp set salR)5== A!e"e empnoR6noK
C:RcG&K
End ifK
End ifK
E6it A!en mPcu"UNO9HOUNDK
End loopK
Close mPcu"K
DbmsPoutput3putPline7c__F"eco"ds !a$e been successfull updatedF:K
EndK
/
8ali3 /est Data0
,"ocedu"e c"eated3
S?lIe6ec mp"ocK
1U/#U/0
@eco"ds !a$e been successfull completed3
/Y c"eate function A!ic! add tAo +i$en numbe"s3 7Simple p"o+"ams: Y/
C"eate o" "eplace function addPfun7a numbe"1b numbe": "etu"n
Numbe" as
C numbe"K
Be+in
C:RaGbK
K.Ravi 85
DBMS Lab Manual
@etu"n cK
EndK
/
Hunction c"eated3
/YaddPfun specificationY/
Decla"e
@esult numbe"K
Be+in
@esult:RaddPfun7&=1)=:K
DbmsPoutput3putPline7Mt!e sum of &= and )= isF__"esult:K
EndK
S?lI/
9!e sum of &= and )= is (=
,l/s?l p"ocedu"e successfull completed3
/Yc"eate a function A!ic! count total no3of emploees !a$in+ sala" less
t!an .===3Y/
/Yfunction bodY/
C"eate o" "eplace function countPemp7esal numbe":"etu"n numbe" as
Cu"so" $inPcu" as Select empno1sal f"om empK
Eno emp3empnoUtpeK
Esal emp3salUtpeK
K.Ravi 86
DBMS Lab Manual
C numbe"K
Be+in
Open $inPcu"K
C:R=K
loop
fetc! $inPcu" into 6no16salK
if76salVesal: t!en
c:RcG&K
end ifK
e6it A!en $inPcu"UnotfoundK
end loopK
close $inPcu"K
"etu"n cK
endK
/
Hunction c"eated3
/Yfunction specificationY/
Decla"e
Ne numbe"K
Esal numbe"K
Be+in
Ne:RcountPemp76sal:K
DbmsPoutput3putPline76sal:K
K.Ravi 87
DBMS Lab Manual
DbmaPoutput3putPline7Mt!e"e a"e M__ne__KemploeesF:K
EndK
/
1U/#U/
9!e"e a"e 4 emploees3
8i4a@8ice0
81 3n mappin* o$ @<! to !F!
a) "n'i'i") in BRD )!$ul# *$((")-$n# '$ an ";i)'ing "n'i'+H)'$(" in D3D
b) "n'i'+ in D3D i) *$nv"('"# '$ a''(ibu'") $& an "n'i'+ in BRD
*) ("la'i$n) in BRD !a) 1 '$ 1 *$((")-$n#"n*" '$ -($*"))") in D3D
#) ("la'i$n)!i-) in BRD !a) 1 '$ 1 *$((")-$n#"n*" '$ &l$6) in D3D
,a) "n'i'i") in BRD )!$ul# *$((")-$n# '$ an ";i)'ing "n'i'+H)'$(" in D3D
82 ( dominant entity is the entity
a) $n '!" 2 )i#" in a 1 = 2 ("la'i$n)!i-
b) $n '!" 1 )i#" in a 1 = 2 ("la'i$n)!i-
*) $n "i'!"( )i#" in a 1 = 1 ("la'i$n)!i-
#) n$'!ing '$ #$ 6i'! 1 = 1 $( 1 = 2 ("la'i$n)!i-
,b) $n '!" 1 )i#" in a 1 = 2 ("la'i$n)!i-
83 6elect EN=<?,E# C>6?=5@< From C>6?F!?A6 Where <@C3=N G ENE =rder By
C>6?=5@< >nion 6elect E@(6?E# C>6?=5@< From C>6?F!?A6 Where <@C3=N G E@E
=rder By C>6?=5@<
!" ab$v" i)
a) 2$' an "(($(
b) B(($( 4 '!" )'(ing in )ingl" 7u$'") G2AREG an# GSACEG
*) B(($( 4 '!" )'(ing )!$ul# b" in #$ubl" 7u$'")
#) B(($( 4 ARDBR B1 *lau)"
,#) B(($( 4 '!" ARDBR B1 *lau)". Sin*" ARDBR B1 *lau)" *ann$' b" u)"# in C2/A2S
84 What is 6tora*e 5ana*er?
/' i) a -($g(a% %$#ul" '!a' -($vi#") '!" in'"(&a*" b"'6""n '!" l$64l"v"l #a'a )'$("# in
#a'aba)". a--li*a'i$n -($g(a%) an# 7u"(i") )ub%i''"# '$ '!" )+)'"%.

85 What is Bu$$er 5ana*er?
/' i) a -($g(a% %$#ul". 6!i*! i) (")-$n)ibl" &$( &"'*!ing #a'a &($% #i)5 )'$(ag" in'$ %ain
%"%$(+ an# #"*i#ing 6!a' #a'a '$ b" *a*!" in %"%$(+.
K.Ravi 88
DBMS Lab Manual
80 What is ?ransaction 5ana*er?
/' i) a -($g(a% %$#ul". 6!i*! "n)u(") '!a' #a'aba)". ("%ain) in a *$n)i)'"n' )'a'" #")-i'"
)+)'"% &ailu(") an# *$n*u(("n' '(an)a*'i$n ";"*u'i$n -($*""#) 6i'!$u' *$n&li*'ing.
84 What is File 5ana*er?
/' i) a -($g(a% %$#ul". 6!i*! %anag") '!" all$*a'i$n $& )-a*" $n #i)5 )'$(ag" an# #a'a
)'(u*'u(" u)"# '$ ("-(")"n' in&$(%a'i$n )'$("# $n a #i)5.
87 What is (uthori/ation and 3nte*rity mana*er?
/' i) '!" -($g(a% %$#ul". 6!i*! '")') &$( '!" )a'i)&a*'i$n $& in'"g(i'+ *$n)'(ain' an#
*!"*5) '!" au'!$(i'+ $& u)"( '$ a**")) #a'a.

88 What are stand-alone procedures?
<($*"#u(") '!a' a(" n$' -a(' $& a -a*5ag" a(" 5n$6n a) )'an#4al$n" b"*au)" '!"+
in#"-"n#"n'l+ #"&in"#. A g$$# ";a%-l" $& a )'an#4al$n" -($*"#u(" i) $n" 6(i''"n in a
SJLF3$(%) a--li*a'i$n. !")" '+-") $& -($*"#u(") a(" n$' availabl" &$( ("&"("n*" &($% $'!"(
A(a*l" '$$l). An$'!"( li%i'a'i$n $& )'an#4al$n" -($*"#u(") i) '!a' '!"+ a(" *$%-il"# a' (un 'i%".
6!i*! )l$6) ";"*u'i$n.
199 What are cursors *i;e di$$erent types o$ cursors
<LHSJL u)") *u()$() &$( all #a'aba)" in&$(%a'i$n a**"))") )'a'"%"n'). !" languag"
)u--$(') '!" u)" '6$ '+-") $& *u()$()
3mplicit
@)plicit
191 What is cold -ac%up and hot -ac%up (in case o$ =racle)?
Cold Bac%up'
/' i) *$-+ing '!" '!("" )"') $& &il") ,#a'aba)" &il"). ("#$ l$g). an# *$n'($l &il")
6!"n '!" in)'an*" i) )!u' #$6n. !i) i) a )'(aig!' &il" *$-+. u)uall+ &($% '!" #i)5 #i("*'l+ '$ 'a-".
1$u %u)' )!u' #$6n '!" in)'an*" '$ gua(an'"" a *$n)i)'"n' *$-+.
/& a *$l# ba*5u- i) -"(&$(%"#. '!" $nl+ $-'i$n availabl" in '!" "v"n' $& #a'a
&il" l$)) i) (")'$(ing all '!" &il") &($% '!" la'")' ba*5u-. All 6$(5 -"(&$(%"# $n '!" #a'aba)" )in*"
'!" la)' ba*5u- i) l$)'.
,ot Bac%up'
S$%" )i'") ,)u*! a) 6$(l#6i#" ai(lin" (")"(va'i$n) )+)'"%)) *ann$' )!u' #$6n
'!" #a'aba)" 6!il" %a5ing a ba*5u- *$-+ $& '!" &il"). !" *$l# ba*5u- i) n$' an availabl" $-'i$n.
S$ #i&&"("n' %"an) $& ba*5ing u- #a'aba)" %u)' b" u)"# K '!" !$' ba*5u-.
/))u" a SJL *$%%an# '$ in#i*a'" '$ A(a*l". $n a 'abl")-a*"4b+4'abl")-a*" ba)i). '!a' '!" &il") $&
'!" 'abl")-a*" a(" '$ ba*5"# u-. !" u)"() *an *$n'inu" '$ %a5" &ull u)" $& '!" &il"). in*lu#ing
%a5ing *!ang") '$ '!" #a'a. An*" '!" u)"( !a) in#i*a'"# '!a' !"H)!" 6an') '$ ba*5 u- '!"
'abl")-a*" &il"). !"H)!" *an u)" '!" $-"(a'ing )+)'"% '$ *$-+ '!$)" &il") '$ '!" #")i("# ba*5u-
#")'ina'i$n.
!" #a'aba)" %u)' b" (unning in ARCE/OBLAD %$#" &$( '!" !$' ba*5u-
$-'i$n.
K.Ravi 89
DBMS Lab Manual
/& a #a'a l$)) &ailu(" #$") $**u(. '!" l$)' #a'aba)" &il") *an b" (")'$("# u)ing
'!" !$' ba*5u- an# '!" $nlin" an# $&&lin" ("#$ l$g) *("a'"# )in*" '!" ba*5u- 6a) #$n". !"
#a'aba)" i) (")'$("# '$ '!" %$)' *$n)i)'"n' )'a'" 6i'!$u' an+ l$)) $& *$%%i''"# '(an)a*'i$n).
192 What are (rmstron* rules? ,o+ do +e say that they are complete andHor sound
!" 6"ll45n$6n in&"("n*" (ul") &$( 3D)
R"&l";iv" (ul" =
/& 1 i) )ub)"' $( "7ual '$ 0 '!"n 0 1.
Aug%"n'a'i$n (ul"=
/& 0 1 '!"n 0P 1P.
(an)i'iv" (ul"=
/& 90 1. 1 P: '!"n 0 P.
D"*$%-$)i'i$n (ul" =
/& 0 1P '!"n 0 1.
Cni$n $( A##i'iv" (ul"=
/& 90 1. 0 P: '!"n 0 1P.
<)"u#$ (an)i'iv" (ul" =
/& 90 1. >1 P: '!"n >0 P.
A& '!")" '!" &i()' '!("" a(" 5n$6n a) A%)'($ng Rul"). !"+ a(" )$un# b"*au)" i' i)
"n$ug! i& a )"' $& 3D) )a'i)&+ '!")" '!("". !"+ a(" *all"# *$%-l"'" b"*au)" u)ing '!")" '!(""
(ul") 6" *an g"n"(a'" '!" (")' all in&"("n*" (ul").
193 ,o+ can you $ind the minimal %ey o$ relational schema?
Mini%al 5"+ i) $n" 6!i*! *an i#"n'i&+ "a*! 'u-l" $& '!" giv"n ("la'i$n )*!"%a uni7u"l+.
3$( &in#ing '!" %ini%al 5"+ i' i) ("7ui("# '$ &in# '!" *l$)u(" '!a' i) '!" )"' $& all a''(ibu'") '!a'
a(" #"-"n#"n' $n an+ giv"n )"' $& a''(ibu'") un#"( '!" giv"n )"' $& &un*'i$nal #"-"n#"n*+.
Algo. I D"'"(%ining 0
N
. *l$)u(" &$( 0. giv"n )"' $& 3D) 3
1. S"' 0
N
8 0
2. S"' Al# 0
N 8
0
N
3. 3$( "a*! 3D 1 P in 3 an# i& 1 b"l$ng) '$ 0
N
'!"n a## P '$ 0
N
4. R"-"a' )'"-) 2 an# 3 un'il Al# 0
N
8 0
N
Algo.II D"'"(%ining %ini%al K &$( ("la'i$n )*!"%a R. giv"n )"' $& 3D) 3
1. S"' K '$ R '!a' i) %a5" K a )"' $& all a''(ibu'") in R
2. 3$( "a*! a''(ibu'" A in K
a. C$%-u'" ,K Q A)
N
6i'! (")-"*' '$ 3
b. /& ,K Q A)
N
8 R '!"n )"' K 8 ,K Q A)
N
194 What do you understand -y dependency preser;ation?
Div"n a ("la'i$n R an# a )"' $& 3D) 3. #"-"n#"n*+ -(")"(va'i$n )'a'") '!a' '!"
*l$)u(" $& '!" uni$n $& '!" -($j"*'i$n $& 3 $n "a*! #"*$%-$)"# ("la'i$n Ri i) "7ual '$ '!"
*l$)u(" $& 3. i."..
,,R1,3)) C R C ,Rn,3)))
N
8 3
N

i& #"*$%-$)i'i$n i) n$' #"-"n#"n*+ -(")"(ving. '!"n )$%" #"-"n#"n*+ i) l$)' in '!"
#"*$%-$)i'i$n.
K.Ravi 90
DBMS Lab Manual

195 What is meant -y &roacti;e# <etroacti;e and 6imultaneous >pdate
&roacti;e >pdate'
!" u-#a'") '!a' a(" a--li"# '$ #a'aba)" b"&$(" i' b"*$%") "&&"*'iv" in ("al
6$(l# .
<etroacti;e >pdate'
!" u-#a'") '!a' a(" a--li"# '$ #a'aba)" a&'"( i' b"*$%") "&&"*'iv" in ("al
6$(l# .
6imulatneous >pdate'
!" u-#a'") '!a' a(" a--li"# '$ #a'aba)" a' '!" )a%" 'i%" 6!"n i' b"*$%")
"&&"*'iv" in ("al 6$(l# .
190 What are the di$$erent types o$ 2=3N operations?
@.ui 2oin' !i) i) '!" %$)' *$%%$n '+-" $& j$in 6!i*! inv$lv") $nl+ "7uali'+
*$%-a(i)i$n). !" #i)a#van'ag" in '!i) '+-" $& j$in i) '!a' '!"("
K.Ravi 91
DBMS Lab Manual
'E* E&estions0
1 Which is the su-set o$ 6BA commands used to manipulate =racle !ata-ase structures#
includin* ta-les?
Da'a D"&ini'i$n Languag" ,DDL)
2 What operator per$orms pattern matchin*?
L/KB $-"(a'$(
3 What operator tests column $or the a-sence o$ data?
/S 2CLL $-"(a'$(
4 Which command e)ecutes the contents o$ a speci$ied $ile?
SAR S&il"na%"T $( US&il"na%"T
5 What is the parameter su-stitution sym-ol used +ith 3N6@<? 3N?= command?
M
0 Which command displays the 6BA command in the 6BA -u$$er# and then e)ecutes it?
RC2
4 What are the +ildcards used $or pattern matchin*?
V &$( )ingl" *!a(a*'"( )ub)'i'u'i$n an# W &$( %ul'i4*!a(a*'"( )ub)'i'u'i$n
7 6tate true or $alse @I36?6# 6=5@# (NJ are operators in 6BA
(u"
8 6tate true or $alse KG# LD# MG all denote the same operation
(u"
19 What are the pri;ile*es that can -e *ranted on a ta-le -y a user to others?
/n)"('. u-#a'". #"l"'". )"l"*'. ("&"("n*"). in#";. ";"*u'". al'"(. all
11 What command is used to *et -ac% the pri;ile*es o$$ered -y the C<(N? command?
RBOAKB
12 Which system ta-les contain in$ormation on pri;ile*es *ranted and pri;ile*es o-tained?
CSBRVABV<R/OSVMADB. CSBRVABV<R/OSVRBCD
13 Which system ta-le contains in$ormation on constraints on all the ta-les created?
CSBRVCA2SRA/2S
14 ?<>NC(?@ ?(BA@ @5&N
!@A@?@ F<=5 @5&N
Will the outputs o$ the a-o;e t+o commands di$$er?
K.Ravi 92
DBMS Lab Manual
B$'! 6ill (")ul' in #"l"'ing all '!" ($6) in '!" 'abl" BM<.
15 What is the di$$erence -et+een ?<>NC(?@ and !@A@?@ commands?
RC2CAB i) a DDL *$%%an# 6!"("a) DBLBB i) a DML *$%%an#. E"n*"
DBLBB $-"(a'i$n *an b" ($ll"# ba*5. bu' RC2CAB $-"(a'i$n *ann$' b" ($ll"# ba*5.
>EBRB *lau)" *an b" u)"# 6i'! DBLBB an# n$' 6i'! RC2CAB.
10 What command is used to create a ta-le -y copyin* the structure o$ another ta-le?
Answer :
CRBAB ABLB .. AS SBLBC *$%%an#
Explanation :
$ *$-+ $nl+ '!" )'(u*'u(". '!" >EBRB *lau)" $& '!" SBLBC *$%%an# )!$ul# *$n'ain
a 3ALSB )'a'"%"n' a) in '!" &$ll$6ing.
CRBAB ABLB 2B>ABLB AS SBLBC F 3RAM B0/S/2DABLB >EBRB 182I
/& '!" >EBRB *$n#i'i$n i) '(u". '!"n all '!" ($6) $( ($6) )a'i)&+ing '!" *$n#i'i$n 6ill b"
*$-i"# '$ '!" n"6 'abl".
14 What +ill -e the output o$ the $ollo+in* .uery?
SELECT REPLACE(TRANSLATE(LTRIM(RTRIM('!! ATHEN !!','!'), '!'), 'AN',
'**'),'*','TROUBLE') FROM DUAL;
RACBLBEBRACBLB
17 What +ill -e the output o$ the $ollo+in* .uery?
6@A@C? !@C=!@(?<(N6A(?@(E(E#E1234504789E#E1111111111E)# E1E#EJ@6E# EN=E )N
Answer :
2A
Explanation :
!" 7u"(+ *!"*5) 6!"'!"( a giv"n )'(ing i) a nu%"(i*al #igi'.
18 What does the $ollo+in* .uery do?
6@A@C? 6(A O NPA(C=55#9) F<=5 @5&N
!i) #i)-la+) '!" '$'al )ala(+ $& all "%-l$+""). !" null valu") in '!" *$%%i))i$n
*$lu%n 6ill b" ("-la*"# b+ 0 an# a##"# '$ )ala(+.
29 Which date $unction is used to $ind the di$$erence -et+een t+o dates?
MA2ESVBB>BB2
21 Why does the $ollo+in* command *i;e a compilation error?
!<=& ?(BA@ Q?(BA@FN(5@N
Oa(iabl" na%") )!$ul# )'a(' 6i'! an al-!ab"'. E"(" '!" 'abl" na%" )'a(') 6i'! an GMG
)+%b$l.
22 What is the ad;anta*e o$ speci$yin* W3?, C<(N? =&?3=N in the C<(N? command?
!" -(ivil"g" ("*"iv"( *an &u('!"( g(an' '!" -(ivil"g") !"H)!" !a) $b'ain"# &($% '!"
$6n"( '$ an+ $'!"( u)"(.
K.Ravi 93
DBMS Lab Manual
23 What is the use o$ the !<=& option in the (A?@< ?(BA@ command?
/' i) u)"# '$ #($- *$n)'(ain') )-"*i&i"# $n '!" 'abl".
24 What is the ;alue o$ RcommS and RsalS a$ter e)ecutin* the $ollo+in* .uery i$ the initial ;alue
o$ RsalS is 19999?
>&!(?@ @5& 6@? 6(A G 6(A O 1999# C=55 G 6(AT91N
)al 8 11000. *$%% 8 1000
25 What is the use o$ !@6C in 6BA?
Answer :
DBSC !a) '6$ -u(-$)"). /' i) u)"# '$ #")*(ib" a )*!"%a a) 6"ll a) '$ ("'(i"v" ($6) &($%
'abl" in #")*"n#ing $(#"(.
Explanation :
!" 7u"(+ SBLBC F 3RAM BM< ARDBR B1 B2AMB DBSC 6ill #i)-la+ '!" $u'-u'
)$('"# $n B2AMB in #")*"n#ing $(#"(.
20 What is the use o$ C(6C(!@ C=N6?<(3N?6?
>!"n '!i) *lau)" i) u)"# 6i'! '!" DRA< *$%%an#. a -a("n' 'abl" *an b" #($--"# "v"n
6!"n a *!il# 'abl" ";i)').
24 Which $unction is used to $ind the lar*est inte*er less than or e.ual to a speci$ic ;alue?
3LAAR
27 What is the output o$ the $ollo+in* .uery?
6@A@C? ?<>NC(12345047#-2) F<=5 !>(AN
1200
K.Ravi 94
DBMS Lab Manual
REFERENCE'0
SCO99 U"man1 o"acle 4i>,L/S0L p"o+"ammin+19MC>)===
Lone1 o"acle 4i>t!e complete "efe"ence19MC>)===
Lone1 o"acle ;i>t!e complete "efe"ence19MC>)===
Ba"oss1 o"acle 9eac! Jou" Self S0L/,LS0L usin+ o"acle 4i and ;i Ait!
S0L81 B,B1 )==)3
Abbe1 o"acle 4i>A be+inne"s +uide19MC>)===3
K.Ravi 95
DBMS Lab Manual
GURU NANAK Engineering College
Ib"a!impatnam1 @ @ Dist"ict - 5=& 5=. 7A3 ,3:
Assi+nment / @eco"d No > PPPPP
Depa"tment of PPPPPPPPPPPPPPPPPPPPPPPP
Name
0 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Class ? Lear ?
'emester
0
." /ech AAAAA Lear AAAAAAAAA 'emester
Roll No"
0 AAAAAAAAAAAAAAAAAAAAAAAAA
'&bHect
0 AAAAAAAAAAAAAAAAAAAAAAAAA
.ranch
0 AAAAAAAAAAAAAAAAAAAAAAAAA
Date o%
'&bmission
0 AAAAA ? AAAAA ? AAAAAAAAAA
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
K.Ravi 96
Anne<&re @ 1
DBMS Lab Manual
't&3ent 'ignat&re Fac&lt) 'ignat&re
In3e< #age
'" No" Date #rogram ? E<periment
#age
No"
'ign ?
Remar=s
K.Ravi 97
Anne<&re @ 5
DBMS Lab Manual
GURU NANAK Engineering College
Ib"a!impatnam1 @ @ Dist"ict - 5=& 5=. 7A3 ,3:
!'ponsore3 b)0 G&r& Nana= E3&cational 'ociet), 2)3eraba3 !A" #"$
Depa"tment of PPPPPPPPPPPPPPPPPPPPPPPP
/his is to certi%) that
Name
0 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Class ? Lear ?
'emester
0
." /ech AAAAAA Lear AAAAAAAA 'emester
Roll No"
0 AAAAAAAAAAAAAAAAAAAAAAAAA
'&bHect
0 AAAAAAAAAAAAAAAAAAAAAAAAA
.ranch
0 AAAAAAAAAAAAAAAAAAAAAAAAA
2as s&ccess%&ll) complete3 the co&rse o% programs ?
K.Ravi 98
Anne<&re @ B
DBMS Lab Manual
e<periments prescribe3 b) 6a9harlal Nerh&
/echnological Uni4erist) o% the 3epartment 3&ring the
aca3emic )ear 500AA @ 500 AA"
AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
Fac&lt) Incharge Department 2ea3
K.Ravi 99

Das könnte Ihnen auch gefallen