Sunteți pe pagina 1din 5

2013

1.
Whati
sFuncti
onaldependency
?Di
scussdi
ff
erent
key
swithsui
tabl
eexamples.
Ans.IfRi
sar
elat
ionwi
that
tri
but
esXandY,
afunct
ional
dependencybet
ween
theat
tri
but
esisr
epr
esentedasX->Y,whichspeci
fi
esYisfuncti
onall
ydependent
onX.HereXisadet
erminantsetandYisadependentatt
ri
bute.Eachval
ueofX
i
sassociat
edwit
hpreci
selyoneYv al
ue.
Functionaldependencyinadat abaseser
vesasaconstr
aintbet
weentwosetsof
att
ributes.Defi
ningfunct
ional
dependencyisanimport
antpartofr
elat
ional
databasedesignandcont ri
butestoaspectnor
mali
zati
on.
Keypl
aysani
mportantrolei
nrel
ati
onaldat
abase;i
tisusedf
ori
dent
if
ying
uni
querowsf
rom t
able.Ital
soest
abli
shesrel
ati
onshi
pamongtabl
es.

Ty
pesofkey
sinDBMS
Pri
maryKey –Apri
maryi
sacolumnorsetofcol
umnsi
nat
abl
ethat
uni
quel
yidenti
fi
est
upl
es(r
ows)int
hatt
able.

SuperKey 
–Asuperkeyi
sasetofoneofmor
ecol
umns(
att
ri
but
es)t
o
uni
quelyi
dent
if
yrowsinatabl
e.

Candi
dat
eKey 
–Asuperkeywi
thnor
edundantat
tri
but
eisknownas
candi
dat
ekey

Alt
ernat
eKey –Outofall
candi
dat
ekey s,
onl
yonegetssel
ectedaspr
imar
y
key,r
emaini
ngkeysareknownasalt
ernat
eorsecondar
ykeys.

Composi
teKey 
–Akeyt hatconsi
stsofmorethanoneatt
ri
butet
ouni
quel
y
i
dent
if
yrows(alsoknownasrecor
ds&t upl
es)inatabl
eiscal
l
ed
composi
tekey
.

Forei
gnKey 
–Forei
gnkeysarethecolumnsofat
ablethatpoi
ntstot
he
pri
marykeyofanot
hert
able.Theyactasacr
oss-
ref
erencebetweent
abl
es.

2.
Whatdoy oumeanbytransact
ion?Di
scussdi
ff
erent
phasesoftr
ansact
ion.
Ans.A transacti
oncanbedef
inedasagr
oupoft
asks.A si
ngl
etaski
sthe
mi
nimum pr
ocessi
nguni
twhi
chcannotbedi
vi
dedf
urt
her
.

Let
’st
akeanexampleofasi
mplet
ransacti
on.Supposeabankempl
oyeetransf
ers
Rs500from A'
saccountt
oB'saccount.Thi
sv er
ysimpl
eandsmalltransact
ion
i
nvol
vessev
eral
low-
lev
elt
asks.

A’
sAccount
Open_Account
(A)
Ol
d_Balance=A.balance
New_Balance=Old_Balance-500
A.
balance=New_ Balance
Cl
ose_Account(
A)

B’
sAccount
Open_Account
(B)
Ol
d_Balance=B.balance
New_Balance=Old_Balance+500
B.
balance=New_ Balance
Cl
ose_Account(
B)

ACI
DPr
ope
rti
es
At r
ansactionisav erysmal luni
tofapr ogram anditmaycont ai
nseverallowlevel
tasks. A t
ransact
ion i
n a database syst
em must
mai nt
ain 
Atomi ci
ty,
 
Consistency,
 I
sol
ati
on,and  Durabil
it
y− commonl yknown as
ACIDpr operti
es−inor dert
oensur eaccuracy,completeness,
anddataintegri
ty.

 At
omi
cit
y −Thi
spr
oper
tyst
atest
hatat
ransact
ionmustbet
reat
edasanat
omi
cuni
t,
t
hati
s,ei
theral
lofi
tsoper
ati
onsar
eexecut
edornone.Ther
emustbenost
atei
na
dat
abasewher
eat
ransact
ioni
slef
tpar
ti
all
ycompl
eted.St
atesshoul
dbedef
ined
ei
therbef
oret
heexecut
ionoft
het
ransact
ionoraf
tert
heexecut
ion/
abor
ti
on/
fai
l
ureof
t
het
ransact
ion.

 Consi
stency
 −Thedat
abasemustr
emai
ninaconsi
stentst
ateaf
teranyt
ransact
ion.
Not
ransact
ionshoul
dhav
eanyadv
erseef
fectont
hedat
aresi
dingi
nthedat
abase.I
f
t
hedat
abasewasi
naconsi
stentst
atebef
oret
heex
ecut
ionofat
ransact
ion,i
tmust
r
emai
nconsi
stentaf
tert
heex
ecut
ionoft
het
ransact
ionaswel
l
.

 Dur
abi
li
ty 
−Thedat
abaseshoul
dbedur
abl
eenought
ohol
dal
li
tsl
atestupdat
esev
eni
f
t
hesy
stem f
ail
sorr
est
art
s.I
fat
ransact
ionupdat
esachunkofdat
ainadat
abaseand
commi
ts,t
hent
hedat
abasewi
l
lhol
dthemodi
fi
eddat
a.I
fat
ransact
ioncommi
tsbut
t
hesy
stem f
ail
sbef
oret
hedat
acoul
dbewr
it
tenont
othedi
sk,t
hent
hatdat
awi
l
lbe
updat
edoncet
hesy
stem spr
ingsbacki
ntoact
ion.

 I
sol
ati
on 
−Inadat
abasesy
stem wher
emor
ethanonet
ransact
ionar
ebei
ngexecut
ed
si
mul
taneousl
yandi
npar
all
el,t
hepr
oper
tyofi
sol
ati
onst
atest
hatal
lthet
ransact
ions
wi
l
lbecar
ri
edoutandexecut
edasi
fiti
stheonl
ytr
ansact
ioni
nthesy
stem.No
t
ransact
ionwi
l
laf
fectt
heexi
stenceofanyot
hert
ransact
ion.

Se
ri
al
iz
abi
l
it
y
When mul t
ipl
et r
ansactionsarebei
ng executed bytheoper
ati
ng syst
em i
na
mult
iprogr
ammi ngenv ir
onment,t
her
ear epossi bi
li
ti
esthati
nst
ruct
ionsofone
t
ransacti
onsareinter
leavedwit
hsomeothertransact
ion.
 Schedul
e −Achr
onol
ogi
calexecut
ionsequenceofat
ransact
ioni
scal
l
edaschedul
e.A
schedul
e can hav
e many t
ransact
ions i
nit
,each compr
isi
ng ofa numberof
i
nst
ruct
ions/
tasks.

 Ser
ialSchedul
e −I
tisaschedul
einwhi
cht
ransact
ionsar
eal
i
gnedi
nsuchawayt
hat
onet
ransact
ioni
sexecut
edf
ir
st.Whent
hef
ir
stt
ransact
ioncompl
etesi
tscy
cle,t
hen
t
henextt
ransact
ioni
sexecut
ed.Tr
ansact
ionsar
eor
der
edoneaf
tert
heot
her
.Thi
s
t
ypeofschedul
eiscal
l
edaser
ialschedul
e,ast
ransact
ionsar
eex
ecut
edi
naser
ial
manner
.

In a mul t
i-
tr
ansaction env i
ronment ,ser i
alschedul es are considered as a
benchmark.Theexecut i
onsequenceofani nstruct
ioni nat r
ansacti
oncannotbe
changed,buttwot ransact
ionscanhav etheirinstr
uctionsexecutedi nar andom
fashi
on.Thisexecuti
ondoesnohar miftwot ransactionsaremut ual
lyindependent
andwor ki
ngondi f
ferentsegment sofdat a;butincaset hesetwot r
ansact i
onsare
worki
ngont hesamedat a,thenther esultsmayv ar
y .Thisever-
varyi
ngr esultmay
bri
ngthedatabasetoani nconsistentstate.

Toresol
vethi
sproblem,weallowparal
lelexecut
ionofatransacti
onschedul
e,i
fit
s
tr
ansact
ionsar
eeitherser
ial
i
zableorhavesomeequi val
encerelat
ionamongthem.

Equi
val
enc
eSc
hedul
es:
Anequi
val
enceschedul
ecanbeoft
hef
oll
owi
ngt
ypes−

Resul
tEqui
val
ence
Iftwoschedulespr
oducethesameresul
taft
erexecut
ion,
theyar
esaidtober esul
t
equivalent
.Theymayyi
eldthesameresul
tforsomevalueanddi
ffer
entresul
tsfor
anothersetofv al
ues.That'
swhyt hi
sequival
enceisnotgeneral
lyconsidered
signi
ficant
.

Vi
ewEqui
val
ence
Twoschedul
eswoul dbevi
ewequiv
alencei
fthet
ransact
ionsi
nbot
htheschedul
es
per
for
m simi
laract
ionsi
nasimi
larmanner.

Forexampl
e−

 I
fTr
eadst
hei
nit
ial
dat
ainS1,
theni
tal
sor
eadst
hei
nit
ial
dat
ainS2.

 I
fTr
eadst
hev
aluewr
it
tenbyJi
nS1,
theni
tal
sor
eadst
hev
aluewr
it
tenbyJi
nS2.

 I
fTper
for
mst
hef
inalwr
it
eont
hedat
aval
uei
nS1,
theni
tal
soper
for
mst
hef
inalwr
it
e
ont
hedat
aval
uei
nS2.

Conf
li
ctEqui
val
ence
Twoschedul
eswoul
dbeconf
li
cti
ngi
ftheyhav
ethef
oll
owi
ngpr
oper
ti
es−

 Bot
hbel
ongt
osepar
atet
ransact
ions.
 Bot
haccessest
hesamedat
ait
em.

 Atl
eastoneoft
hem i
s"wr
it
e"oper
ati
on.

Twoschedul
eshavingmulti
pletr
ansact
ionswi
thconf
li
cti
ngoper
ati
onsar
esai
dto
beconf
li
ctequi
val
entifandonlyi
f−

 Bot
htheschedul
escont
aint
hesamesetofTr
ansact
ions.

 Theor
derofconf
li
cti
ngpai
rsofoper
ati
oni
smai
ntai
nedi
nbot
htheschedul
es.

Note −View equi
val
entschedul
esarevi
ew ser
ial
i
zableandconfl
ictequi
val
ent
schedulesareconfl
i
ctseri
ali
zabl
e.Al
lconf
li
ctseri
ali
zabl
eschedulesarevi
ew
seri
ali
zabl
etoo.

St
ate
sofTr
ans
act
i
ons
At
ransact
ioni
nadat
abasecanbei
noneoft
hef
oll
owi
ngst
ates−

 Act
ive 
−Int
hisst
ate,
thet
ransact
ioni
sbei
ngexecut
ed.Thi
sist
hei
nit
ialst
ateofev
ery
t
ransact
ion.

 Par
ti
all
yCommi
tt
ed 
−Whenat
ransact
ionexecut
esi
tsf
inaloper
ati
on,
iti
ssai
dtobei
n
apar
ti
all
ycommi
tt
edst
ate.

 Fai
led 
−At
ransact
ioni
ssai
dtobei
naf
ail
edst
atei
fanyoft
hechecksmadebyt
he
dat
abaser
ecov
erysy
stem f
ail
s.Af
ail
edt
ransact
ioncannol
ongerpr
oceedf
urt
her
.

 Abor
ted 
−Ifanyoft
hechecksf
ail
sandt
het
ransact
ionhasr
eachedaf
ail
edst
ate,
then
t
her
ecov
erymanagerr
oll
sbackal
lit
swr
it
eoper
ati
onsont
hedat
abaset
obr
ingt
he
dat
abasebackt
oit
sor
igi
nal
stat
ewher
eitwaspr
iort
otheexecut
ionoft
het
ransact
ion.
Tr
ansact
ionsi
nthi
sst
atear
ecal
l
edabor
ted.Thedat
abaser
ecov
erymodul
ecansel
ect
oneoft
het
wooper
ati
onsaf
terat
ransact
ionabor
ts−
o Re-
star
tthet
ransact
ion

o Ki
l
lthet
ransact
ion

 Commi
tt
ed 
−Ifat
ransact
ionexecut
esal
lit
soper
ati
onssuccessf
ull
y,i
tissai
dtobe
commi
tt
ed.Al
li
tsef
fect
sar
enowper
manent
lyest
abl
i
shedont
hedat
abasesy
stem.

S-ar putea să vă placă și