Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Trng i Hc Bch Khoa - Tp.

HCM
Khoa Khoa Hc & K Thut My Tnh
***
M : 01
thi cui k
Mn: H Qun Tr C S D Liu (503004)
Ngnh: Khoa Hc My Tnh HK2 2011-2012
Thi gian lm bi: 120 pht
(Bi thi gm 45 cu hi. Sinh vin c tham kho ghi ch trong 2 t giy A4.)
Sinh vin chn 1 cu tr li ng nht. Nu chn cu (e) th sinh vin cn trnh by p n khc
so vi p n cc cu (a), (b), (c), v (d) v/hoc gii thch la chn (e) ca mnh.

Cu 1. H qun tr c s d liu quan h (relational
database management system) khc h qun tr c s
d liu XML (XML database management system)
c im g sau y?
a. H qun tr c s d liu quan h l phn mm
chuyn dng h tr to, qun l, bo tr bn vng cho
nhiu c s d liu c kch thc ln; trong khi ,
h qun tr c s d liu XML h tr cho nhng c
s d liu c kch thc tng i nh.
b. H qun tr c s d liu quan h l h qun tr c
s d liu h tr cc c s d liu quan h; trong khi
, h qun tr c s d liu XML h tr cc c s d
liu XML.
c. H qun tr c s d liu quan h cung cp nhiu
tin ch cho vic x l v ti u ha truy vn c s
d liu quan h; trong khi , h qun tr c s d
liu XML ch yu h tr vic trao i d liu vi
nh dng XML.
d. H qun tr c s d liu quan h gip qun l v
x l giao tc ca nhiu ngi dng khc nhau trong
mi trng a ngi dng; trong khi , h qun tr
c s d liu XML gip qun l v x l giao tc
trong mi trng n ngi dng.
e. kin khc.

Cu 2. Cc cu lnh v nh ngha d liu (data
definition statement) do ai gi n h qun tr c s
d liu?
a. Cc chng trnh ng dng (application program)
chy trn h qun tr c s d liu
b. Ngi s hu d liu (data owner)
c. Ngi thit k c s d liu (database designer)
d. Ngi qun tr c s d liu (database
administrator DBA)
e. kin khc.

Cu 3. Trong h qun tr c s d liu Oracle,
ngi s dng c th s dng hints (/*+ . */)
dn hng cho b ti u ha truy vn (query
optimization) trong qu trnh x l truy vn. Khi ,
Oracle gi nh iu g sau y?
a. Cu truy vn c hints cha c nh ngha trc
trn d liu ca ngi s dng.
b. Ngi s dng c nhiu thng tin hn v t chc
d liu (data organization) v cc phng thc truy
t (access method) trn d liu ca ngi s dng so
vi b ti u ha truy vn ca Oracle.
c. B ti u ha truy vn ca Oracle khng c
thng tin v cc phng thc truy t trn d liu ca
ngi s dng.
d. Qu trnh x l truy vn ca Oracle c chuyn
sang ch do ngi dng ch nh (user-specified
mode).
e. kin khc.

Cu 4. Vic tm kim cc bn ghi trong mt tp tin
d liu vi iu kin tm kim >= trn mt vng tin
A1 ca tp tin s hiu qu hn khi tp tin c t
chc dng no?
a. Tp tin c th t theo cc gi tr ca vng tin A1.
b. Tp tin c th t theo cc gi tr ca vng tin A2.
A2 l mt trong s nhng vng tin khc ca tp tin.
c. Tp tin bm theo cc gi tr ca vng tin A1.


2
d. Tp tin khng c th t theo cc gi tr ca vng
tin A1.
e. kin khc.

Cu 5. Xc nh chi ph truy t khi trung bnh
trn tp tin d liu bm (hashed file) khi iu kin
tm kim trn vng tin bm (hashing field) l =.
Cho bit b l s khi d liu hin c trong tp tin.
a. O(1)
b. O(log
2
b)
c. O(lnb)
d. O(b)
e. kin khc.

Cu 6. Vi kch thc khi (block size) B = 512
bytes, s lng con tr cy p mi nt trong cy ch
mc B-tree l 24 v s lng con tr cy p mi nt
ni trong cy ch mc B+-tree l 34 v mi nt l
trong cy ch mc B+-tree l 31. Chn pht biu SAI
v s khc bit gia B-tree v B+-tree?
a. Kh nng ch mc ca B+-tree cao (hiu qu) hn
B-tree vi h s r nhnh (fan-out) ln hn: 34 > 24.
b. Kh nng ch mc ca B+-tree cao (hiu qu) hn
B-tree vi s mc (entry) ti a ca mi nt ni ln
hn: 33 > 23.
c. Nu hai cy B-tree v B+-tree ny c cng chiu
cao th tng s con tr d liu (data pointer) trong
B+-tree ln hn nhiu so vi trong B-tree.
d. Khng th so snh c hai cy B-tree v B+-tree
vi phn m t trn.
e. kin khc.

Cu 7. Cho tp tin d liu gm 6 khi d liu cha
cc bn ghi c sp th t vt l theo cc gi tr ca
vng tin kha ID (key field) vi h s phn khi
(blocking factor) bfr = 2 bn ghi/khi. Mt ch mc
s cp a mc (multilevel primary index) dng cu
trc ch mc B-tree vi bc p = 3 c nh ngha
trn vng tin ID. Xc nh ch mc B-tree NG
trn tp tin d liu ny.
a. Hnh 1
b. Hnh 2
c. Hnh 3
d. Hnh 4
e. kin khc.


Tp tin d liu gm 6 blocks vi h s phn khi
bfr = 2 bn ghi/khi v ni dung vng tin kha ID.

Cu 8. Cho ch mc B+-tree trn vng tin kha
SSN (key field) ca tp tin d liu Employee. Cc gi
tr ca vng tin kha SSN khng c dng sp
th t cc bn ghi ca tp tin d liu Employee. Ch
mc B+-tree ny c gi tn l g?
a. Ch mc s cp (primary index)
b. Ch mc cm (clustering index)
c. Ch mc th cp (secondary index)
d. Khng chi tit m t v ch mc ny nn khng
th kt lun c dng ca ch mc ny.
e. kin khc.

Cu 9. Cho mt ch mc th cp a mc (multilevel
secondary index) trn thuc tnh kha m nhn vin
EID ca tp tin d liu Employee dng cu trc B+-
tree trong Hnh 5. Cc bn ghi ca tp tin c t
chc theo cch phn khi khng ph (unspanned
blocking) vi h s phn khi (blocking factor) bfr =
3. Xc nh s khi d liu hin c (the current
number of blocks) trong tp tin d liu Employee.
a. 3 khi
b. 4 khi


3
c. 6 khi
d. 11 khi
e. kin khc.

Cu 10. Xc nh s khi d liu hin c trong ch
mc th cp a mc B+-tree Hnh 5.
a. 11 khi
b. 17 khi
c. 22 khi
d. 41 khi
e. kin khc.

Cu 11. A l nhn vin mi ca t chc v c m
nhn vin l 4. Mt bn ghi v A c thm vo tp
tin Employee. Xc nh s truy t khi (the number
of block accesses) cn thc hin khi cp nht thng
tin ch mc cho bn ghi v A trong ch mc th cp
a mc B+-tree Hnh 5.
a. 3
b. 4
c. 5
d. 6
e. kin khc.

Cu 12. Cho cng thc tnh chi ph cho php ton
chn (selection) dng ch mc th cp vi cu trc
ch mc a mc ng B+-tree trong trng hp iu
kin chn l iu kin = trn thuc tnh c ch
mc: C = x + s; trong , x l s mc ca B+-tree, s
l s lng bn ghi tr v trong kt qu ca php
chn. ngha ca x v s trong cng thc l g?
a. x l chi ph duyt ht cc khi tng mc trn ch
mc n c khi ch mc cha cc con tr d
liu tnh theo s truy t khi; s l chi ph chn t tp
tin d liu ra cc khi d liu cha cc bn ghi trong
kt qu tnh theo s truy t khi.
b. x l chi ph duyt mt s khi tng mc trn ch
mc n c khi ch mc cha cc con tr d
liu tnh theo s truy t khi; s l chi ph chn t tp
tin d liu ra cc khi d liu cha cc bn ghi trong
kt qu tnh theo s truy t khi.
c. x l chi ph duyt mt khi tng mc trn ch
mc n c khi ch mc cha cc con tr d
liu tnh theo s truy t khi (block access); s l chi
ph chn t tp tin d liu ra cc khi d liu cha
cc bn ghi trong kt qu t cc con tr d liu trong
ch mc tnh theo s truy t khi.
d. x l chi ph duyt cc khi trn ch mc n
c cc khi ch mc cha cc con tr d liu
tng mc tnh theo s truy t khi; s l chi ph chn
t tp tin d liu ra cc khi d liu cha cc bn ghi
trong kt qu t cc con tr d liu trong ch mc
tnh theo s truy t khi.
e. kin khc.

Cu 13. Cho cng thc tnh chi ph cho php ton
chn (selection) dng ch mc th cp vi cu trc
ch mc a mc ng B+-tree trong trng hp iu
kin chn l iu kin >= trn thuc tnh c ch
mc: C = x + bl1/2 + r/2; trong , x l s mc ca
B+-tree, bl1 l s khi ch mc tng l, r l s bn
ghi trong tp tin d liu. Gi nh (assumption) g
c s dng trong cng thc ny?
a. Phn na s nt trong ch mc cha cc con tr d
liu ch n cc bn ghi trong kt qu ca php chn.
b. Phn na s khi ch mc tng l chnh l s
khi cha cc bn ghi trong kt qu ca php chn.
c. Ch phn na s khi d liu trong tp tin cn c
kim tra iu kin chn.
d. Phn na s bn ghi trong tp tin tha iu kin
chn.
e. kin khc.

Cu 14. Cho kch thc vng m (buffer) l bf = 5
khi (blocks). Tp tin d liu Employee gm 16 khi
d liu (b
E
= 16 blocks). Tp tin d liu Department
gm 7 khi d liu (b
D
= 7 blocks). Thc hin php
kt vi iu kin kt bng gia thuc tnh DNO ca
Employee v DNUMBER ca Department:
Employee
DNO = DNUMBER
Department. Xc nh
tng s truy t khi (block accesses) trn cc tp tin
d liu nu php kt ny c x l bng phng
php hai vng lp lng (nested-loop join).
a. 112 block accesses nu Department vng lp
ngoi (outer loop).
b. 53 block accesses nu Department vng lp
ngoi.
c. 32 block accesses nu Employee vng lp ngoi.
d. 23 block accesses nu Employee vng lp ngoi.
e. kin khc.



4
Phn gi thit sau c s dng cho cc cu 15-17.
Cho lc c s d liu gm hai bng
EMPLOYEE (ng vi tp tin d liu EMPLOYEE)
v DEPARTMENT (ng vi tp tin d liu
DEPARTMENT) c nh ngha di y. Cc
thng tin cho vic truy t d liu trong cc tp tin d
liu EMPLOYEE v DEPARTMENT cng c cho
tng ng.





Tp tin EMPLOYEE c:

S lng bn ghi r
E
= 5000 records.
S lng khi b
E
= 1000 blocks.
H s phn khi bfr
E
= 5 records/block.

Trn thuc tnh kha SSN, mt ch mc th cp
(secondary index) c nh ngha gm 3 mc (x
SSN

= 3) vi lng bn ghi c chn trung bnh l s
SSN
=
1 v s lng khi tng c s (tng l) l bl1
SSN
=
30.

Trn thuc tnh khng kha SALARY, mt ch mc
cm (clustering index) c nh ngha gm 3 mc
(x
SALARY
= 3), s lng khi tng c s (tng l)
bl1
SALARY
= 20 blocks, v lng bn ghi c chn
trung bnh (average selection cardinality) s
SALARY
=
20.

Trn thuc tnh khng kha DNO, mt ch mc th
cp (secondary index) c nh ngha gm 2 mc
(x
DNO
= 2), s lng khi tng c s (tng l)
bl1
DNO
= 4 blocks, s lng gi tr phn bit ti thuc
tnh DNO l d
DNO
= 80, v lng bn ghi c chn
trung bnh s
DNO
= r
E
/d
DNO
= 62.

Tp tin DEPARTMENT c:

S lng bn ghi r
D
= 80 records.
S lng khi b
D
= 10 blocks.
H s phn khi bfr
D
= 8 records/block.

Trn thuc tnh kha DNUMBER, mt ch mc s
cp c nh ngha gm 1 mc (x
DNUMBER
= 1) vi
lng bn ghi c chn trung bnh l s
DNUMBER
= 1.

Trn thuc tnh khng kha MGRSSN, mt ch mc
th cp c nh ngha gm 2 mc (x
MGRSSN
= 2)
vi lng bn ghi c chn trung bnh l s
MGRSSN
=
1 v s lng khi tng c s l bl1
MGRSSN
= 2.

Cho trc cc hm tnh chi ph ca php chn v
php kt nh sau:

Cost Functions for SELECT:
S1. Linear search (brute force) approach:
C
S1a
= b
For an equality condition on a key, C
S1b
= (b/2) if
the record is found; otherwise C
S1a
= b.
S2. Binary search:
C
S2
= log
2
b + (s/bfr) - 1
For an equality condition on a unique (key)
attribute: C
S2
=log
2
b
S3. Using a primary index (S3a) or hash key
(S3b) to retrieve a single record:
C
S3a
= x + 1; C
S3b
= 1 for static or linear hashing;
C
S3b
= 2 for extendible hashing
S4. Using an ordering index to retrieve
multiple records:
For the comparison condition on a key field with
an ordering index: C
S4
= x + (b/2)
S5. Using a clustering index to retrieve
multiple records for an equality condition:
C
S5
= x + (s/bfr)
S6. Using a secondary (B
+
-tree) index:
For an equality comparison (=): C
S6a
= x + s
For a comparison condition (>, <, >=, or <=):
C
S6b
= x + (bl1/2) + (r/2)



5
Cost Functions for JOIN:
J1. Nested-loop join:
C
J1
= b
R
+ (b
R
*b
S
) + ((js* |R|* |S|)/bfr
RS
)
(Use R for outer loop)
J2. Single-loop join(using an access structure to
retrieve the matching record(s))
For a secondary index:
C
J2a
= b
R
+ (|R| * (x
B
+ s
B
)) + ((js* |R|* |S|)/bfr
RS
)
For a clustering index:
C
J2b
= b
R
+ (|R| * (x
B
+ (s
B
/bfr
B
))) + ((js* |R|*
|S|)/bfr
RS
)
For a primary index:
C
J2c
= b
R
+ (|R| * (x
B
+ 1)) + ((js* |R|* |S|)/bfr
RS
)
If a hash key exists for one of the two join
attributes B of S:
C
J2d
= b
R
+ (|R| * h) + ((js* |R|* |S|)/bfr
RS
)
(h: the average number of block accesses to retrieve a
record, given its hash key value, h>=1)
J3. Sort-merge join:
C
J3a
= C
S
+ b
R
+ b
S
+ ((js* |R|* |S|)/bfr
RS
)
(C
S
: cost for sorting files)

Cu 15. Cho biu thc truy vn chn ra nhng nhn
vin c lng bng 1000 v nhng phng ban c
m ln hn 5:
SALARY=1000 AND DNO>5
(EMPLOYEE).
Xc nh chi ph ca bn k hoch thc thi c
chn nu dng ti u ha truy vn da trn chi ph
(cost-based optimization).
a. 7 block accesses
b. 20 block accesses
c. 1000 block accesses
d. 2000 block accesses
e. kin khc.

Cu 16. Cho biu thc truy vn chn ra phng ban
c qun l bi nhn vin c m 123456789:

MGRSSN=123456789
(DEPARTMENT). Da trn ti u
ha truy vn dng chi ph, k hoch thc thi
(execution plan) no sau y l hp l nht cho biu
thc truy vn ny?
a. Phng php tm kim tuyn tnh trn vng tin
MGRSSN vi chi ph l 10 block accesses
b. Phng php ch mc th cp trn vng tin
MGRSSN vi chi ph l 2 block accesses
c. Phng php ch mc th cp trn vng tin
MGRSSN vi chi ph l 3 block accesses
d. Phng php ch mc th cp trn vng tin
MGRSSN vi chi ph l 43 block accesses
e. kin khc.

Cu 17. Cho cu lnh SQL nh sau:
SELECT *
FROM EMPLOYEE AS E JOIN EMPLOYEE AS S
ON E.SUPERSSN = S.SSN;
Cho trc chn lc kt (join selectivity) dnh cho
biu thc truy vn trn l js = 1/r
E
= 1/5000; h s
phn khi ca tp tin kt qu kt t biu thc truy
vn trn l bfr
EE
= 6 records/block.
Khi x l biu thc truy vn trn dng phng php
kt hai vng lp lng nhau (nested loop join) v kt
mt vng lp (single loop join) da trn ti u ha
truy vn dng chi ph, k hoch thc thi (execution
plan) no sau y l hp l nht cho biu thc truy
vn ny?
a. Phng php nested loop join vi EMPLOYEE
(SSN) vng lp ngoi.
b. Phng php nested loop join vi EMPLOYEE
(SUPERSSN) vng lp ngoi.
c. Phng php single-loop join vi EMPLOYEE
(SSN) trn vng lp.
d. Phng php single-loop join vi EMPLOYEE
(SUPERSSN) trn vng lp.
e. kin khc.

Cu 18. Mt giao tc (transaction) khng b ngng
thc thi gia chng (aborted) trong tnh hung no?
a. Li t cc tc v c/ghi d liu trong giao tc xy
ra.
b. Li tt ngun xy ra.
c. Yu cu ngng thc thi t trnh iu khin tng
tranh (concurrency controller) c thc hin.
d. Lng tc v c/ghi d liu trong giao tc (long
transaction) c thc hin nhiu.
e. kin khc.

Cu 19. Cho cc trnh t thc thi ca cc tc v trong
cc giao tc khc nhau. Xc nh trnh t thc thi
NG l mt lch biu (schedule).
Giao tc T1: r
1
(X); w
1
(X); r
1
(Y); w
1
(Y); r
1
(X)


6
Giao tc T2: r
2
(Y); r
2
(X); w
2
(X); w
2
(Y)
a. Trnh t S1: r
1
(X); r
2
(Y); w
2
(Y); w
1
(X); r
1
(Y);
r
2
(X); w
2
(X); w
1
(Y); r
1
(X)
b. Trnh t S2: r
1
(X); w
1
(X); r
2
(Y); r
2
(X); r
1
(Y);
w
1
(Y); w
2
(X); w
2
(Y); r
1
(X)
c. Trnh t S3: r
2
(Y); r
2
(X); r
1
(X); r
1
(Y); r
1
(X);
w
1
(X); w
1
(Y); w
2
(X); w
2
(Y)
d. Trnh t S4: r
2
(Y); w
2
(Y); r
1
(X); w
1
(X); r
1
(X);
r
1
(Y); w
1
(Y); r
2
(X); w
2
(X)
e. kin khc.

Cu 20. Cho lch biu S5: r
1
(X); r
2
(Z); r
1
(Z); r
3
(X);
r
3
(Y); w
1
(X); w
3
(Y); r
2
(Y); w
2
(Z); w
2
(Y); c
1
; c
2
; c
3
.
Xc nh c im kh phc hi (recoverability) ca
S5.
a. Kh phc hi (recoverable)
b. Khng dt dy (cascadeless)
c. Nghim cch (strict)
d. Khng kh phc hi (non-recoverable)
e. kin khc.

Cu 21. Cho lch biu S6: r
2
(X); r
1
(Y); w
2
(X); r
3
(X);
w
1
(Y); w
3
(X); r
2
(Y); w
2
(Y). Xc nh c im kh
tun t ha (serializability) ca S6.
a. S6 kh tun t ha xung t (conflict serializable).
b. S6 khng kh tun t ha (non-serializable).
c. Thng tin m t v lch biu S6 khng y nn
khng th xc nh c c im kh tun t ha
ca S6.
d. S6 khng c c im kh tun t ha.
e. kin khc.

Cu 22. Lch biu S7 l mt lch biu kh tun t ha
khng dt dy (serializable and cascadeless
schedule). Chn pht biu SAI v lch biu S7.
a. Tn ti mt lch biu tun t tng ng
(equivalent serial schedule) vi lch biu S7.
b. S ghi h thng (system log) khng cn c mc tin
(entry) v cc tc v c (read operation) ca cc
giao tc trong lch biu S7.
c. Khi mt giao tc trong lch biu S7 b ngng thc
thi (aborted), khng c giao tc no khc trong lch
biu S7 cng b ngng thc thi ko theo.
d. Vic phc hi dnh cho lch biu S7 s d dng
hn so vi cc lch biu kh tun t ha nghim cch
(serializable and strict schedule).
e. kin khc.

Cu 23. Chn pht biu NG v commit point ca
mt giao tc T.
a. im m khi , tt c cc tc v ca T c
thc hin thnh cng v nhng tc ng ca T ln c
s d liu c ghi nhn trong s ghi h thng
(system log).
b. im m khi , tt c cc tc v ca T c
thc hin thnh cng v nhng tc ng ca T ln c
s d liu c ghi nhn trong c s d liu.
c. im m khi , tt c cc tc v ca T c
tho g thnh cng v nhng tc ng ca T ln c
s d liu c xa khi s ghi h thng.
d. im m khi , tt c cc tc v ca T c
tho g thnh cng v nhng tc ng ca T ln c
s d liu c xa khi c s d liu.
e. kin khc.

Cu 24. Cho lch biu S8: r
1
(X); r
2
(Z); r
1
(Z); r
3
(X);
r
3
(Y); w
1
(X); w
3
(Y); r
2
(Y); w
2
(Z); w
2
(Y). Xc nh
lch biu tun t tng ng (equivalent serial
schedule) ca S8 nu c.
a. T3; T1; T2
b. T1; T2; T3
c. T3; T2; T1
d. S khng kh tun t ha. Do , khng tn ti lch
biu tun t tng ng ca S8.
e. kin khc.

Cu 25. Cho X = 5 v Y = 10 trong c s d liu
(database - DB). Hai giao tc T1 v T2 thc thi ng
thi trong mi trng a ngi dng nhng iu
khin tng tranh khng c thc hin nh sau:

T1 T2 X (DB) Y (DB)
5 10
Read_item(X);
X := X-5;
Read_item(X);
X := X + 3;
Write_item(X); 0
Read_item(Y);


7
Y := Y * 2;
Write_item(X); 8
Write_item(Y); 20
Commit;
Commit;

Gi tr hin ti ca X l 8 v gi tr hin ti ca Y l
20 trong c s d liu. Cc gi tr ny NG hay
SAI?
a. NG
b. SAI
c. Khng th xc nh c do cc gi tr ca X v Y
cn c so snh vi cc gi tr tng ng trong s
ghi h thng (system log).
d. Khng th xc nh c do thiu thng tin m t
v mi trng thc thi ca cc giao tc.
e. kin khc.

Cu 26. Trong mi trng thc thi n ngi dng
(single-user execution environment), h qun tr c
s d liu khng cn kim tra cho c tnh no ca
giao tc?
a. Tnh nguyn t (atomicity)
b. Tnh nht qun (consistency)
c. Tnh cch ly (isolation)
d. Tnh bn vng (durability)
e. kin khc.

Cu 27. Xc nh lch biu m trong , k thut
kha hai pha (two-phase locking) c s dng
NG.
a. Lch biu S9
T1 T2
Read_lock(X)
Read_item(X)
Read_lock(X)
Read_item(X)
Write_lock(Y)
Unlock(X)
Read_item(Y)
Unlock(X)
Write_item(Y)
Unlock(Y)

b. Lch biu S10
T1 T2
Read_lock(X)
Read_item(X)
Read_lock(X)
Read_item(X)
Unlock(X)
Write_lock(Y)
Write_lock(X)
Write_item(Y)
Unlock(Y)
Write_item(X)
Unlock(X)

c. Lch biu S11
T1 T2
Read_lock(X)
Read_item(X)
Read_lock(X)
Read_item(X)
Write_lock(Y)
Unlock(X)
Write_item(Y)
Unlock(X)
Write_lock(X)
Write_item(X)
Unlock(Y)
Unlock(X)

d. Lch biu S12
T1 T2
Read_lock(X)
Read_item(X)


8
Read_lock(X)
Read_item(X)
Write_lock(Y)
Unlock(X)
Write_item(Y)
Unlock(Y)
Write_item(X)
Unlock(X)

e. kin khc.

Cu 28. Cho th i (wait-for graph) ca mt lch
biu di y m trong , iu khin tng tranh
ca cc giao tc c thc hin vi k thut kha hai
pha. Kha cht (deadlock) c xy ra vi lch biu
ny khng?

a. Khng thng tin v cc giao tc xc nh liu
kha cht c xy ra hay khng.
b. Ch khi cc giao tc t n im commit, th
i mi c y thng tin v khi , vic xc nh
liu kha cht c xy ra hay khng mi c xc
nh ng.
c. C
d. Khng
e. kin khc.

Cu 29. iu g lun NG vi cc tc v ca cc
giao tc c iu khin tng tranh bng k thut
kha hai pha a phin bn vi kha chng nhn
(multiversion two-phase locking using certify locks)?
a. Tc v read(X) s b t chi nu khng tm thy
c phin bn d liu ng cho yu cu c ca
giao tc.
b. Tc v read(X) khng bao gi b t chi (rejected).

c. Tc v write(X) khng bao gi b t chi.
d. Tc v write(X) s b b qua (ignored) nu c giao
tc khc tr hn giao tc yu cu ghi c d liu
X.
e. kin khc.

Cu 30. Cho lch biu S13 sau y m trong , cc
giao tc T1 v T2 thc thi ng thi di k thut
iu khin tng tranh kha hai pha a phin bn vi
kha chng nhn.

Lch biu S13:
T1 T2
Write_lock(Y)
Read_lock(Y)
Read_lock(X)
Read_item(Y)
Write_item(Y)
Read_item(X)
Unlock(Y)
Commit
Certify_lock(Y)


Giao tc T1 c th c c certify lock trn d liu Y
trc khi T1 commit hay khng?
a. T1 khng th c c certify lock trn Y do T2
c d liu Y trc khi T1 cp nht d liu Y.
b. T1 c c certify lock trn Y do certify lock
tng thch vi read lock v xung t loi tr vi
write lock v T2 ch gi read lock trn Y.
c. T1 c c certify lock trn Y do khng c giao
tc no khc ang gi read lock trn Y.
d. Khng thng tin m t v lch biu nn khng
th xc nh c liu T1 c th c c certify lock
trn d liu Y hay khng.
e. kin khc.

Cu 31. Xc nh lch biu tun t tng ng
(equivalent serial schedule) vi lch biu S14 sau y
khi cc giao tc ca S14 c iu khin tng tranh
bng k thut sp th t theo nhn thi gian
(timestamp ordering).

Lch biu S14:
T1 T2 T3 T4 A
TS=150 TS=200 TS=175 TS=225 Read_TS=0;
Write_TS=0


9
R
1
(A) Read_TS=150
W
1
(A) Write_TS=150
R
2
(A) Read_TS=200
W
2
(A) Write_TS=200
R
3
(A)
Abort
R
4
(A) Read_TS =
225

a. T4; T2; T3; T1
b. T3; T2; T1; T4
c. T1; T3; T2; T4
d. T2; T3; T4; T1
e. kin khc.

Cu 32. Cho lch biu S15 trong Bng 1 m trong
, vic iu khin tng tranh ca cc giao tc c
thc hin bng k thut a phin bn da trn sp th
t theo nhn thi gian (multiversion technique based
on timestamp ordering). Vic g xy ra khi giao tc
T3 c A, ngha l r
3
(A) din ra?
a. Giao tc T3 b ngng thc thi (aborted).
b. Tc v c ca giao tc T3 b tr hon thc thi
(delayed).
c. Tc v c ca giao tc T3 b b qua (ignored).
d. Tc v c ca giao tc T3 c thc hin vi
phin bn A150.
e. kin khc.

Cu 33. Gi nh (assumption) g c s dng
trong k thut iu khin tng tranh xc nhn hp l
lc quan (validation (optimistic) concurrency control
technique)?
a. S can thip ln nhau (interference) gia cc giao
tc trong lch biu thp.
b. S can thip ln nhau gia cc giao tc trong lch
biu cao.
c. Khng tn ti s can thip ln nhau gia cc giao
tc trong lch biu.
d. Khng c gi nh g v s can thip ln nhau gia
cc giao tc trong lch biu.
e. kin khc.

Cu 34. Trong k thut iu khin tng tranh xc
nhn hp l lc quan, vic cp nht d liu X ca mt
giao tc T s c thc hin nh th no?
a. Gi tr mi ca d liu X c ghi nhn vo c s
d liu v cc giao tc khc c th thy cp nht ny
khi c d liu X t c s d liu.
b. Gi tr mi ca d liu X c ghi nhn thnh cc
phin bn cc b ca giao tc T v cc giao tc khc
khng th thy cp nht ny khi c d liu X.
c. Gi tr mi ca d liu X c ghi nhn vo s ghi
h thng (system log) v cc giao tc khc c th thy
cp nht ny t vic c s ghi h thng.
d. Gi tr mi ca d liu X c ghi nhn thnh cc
phin bn cc b ca giao tc T v cc giao tc khc
c th thy cp nht ny khi lin lc vi giao tc T.
e. kin khc.

Cu 35. Trong ma trn tng thch kha (lock
compatibility matrix) di y ca k thut kha a
mc d liu (multiple granularity locking technique),
kha SIX (shared-intention-exclusive) tng thch
vi kha no?



a. IS
b. IX
c. S
d. SIX
e. kin khc.

Cu 36. Cho phn cp c s d liu trong Hnh 6.
Giao tc T1 thc hin cc tc v sau: c trang p
21
v
cp nht bn ghi r
211
. Xc nh vic kha a mc d
liu c thc hin trong T1 vi k thut kha a
mc d liu.

a. IX(db)


10
IX(f
2
)
S(p
21
)
Read(p
21
)
IX(p
21
)
X(r
211
)
Write(r
211
)
Unlock(r
211
)
Unlock(p
21
)
Unlock(p
21
)
Unlock(f
2
)
Unlock(db)

b. IX(db)
IX(f
2
)
IX(p
21
)
X(r
211
)
Read(p
21
)
Write(r
211
)
Unlock(r
211
)
Unlock(p
21
)
Unlock(f
2
)
Unlock(db)

c. IX(db)
IX(f
2
)
SIX(p
21
)
Read(p
21
)
X(r
211
)
Write(r
211
)
Unlock(r
211
)
Unlock(p
21
)
Unlock(f
2
)
Unlock(db)

d. IX(db)
IX(f
2
)
S(p
21
)
Read(p
21
)
Unlock(p
21
)
Unlock(f
2
)
Unlock(db)
IX(db)
IX(f
2
)
IX(p
21
)
X(r
211
)
Write(r
211
)
Unlock(r
211
)
Unlock(p
21
)
Unlock(f
2
)
Unlock(db)

e. kin khc.

Cu 37. Cp nht tc thi (immediate update) l g?
a. Ngay khi d liu b cp nht trong b nh cache,
thay i cng s c thc hin trn a.
b. Ngay khi d liu b cp nht trong b nh cache,
thay i cng s c thc hin trn s ghi h
thng (system log).
c. Ngay khi d liu b cp nht trong b nh cache,
thay i cng s c ghi nhn thnh phin bn
cc b ca giao tc.
d. Ngay khi d liu b cp nht trong b nh cache,
thay i cng s c thc hin trn vng a
ring gi l cc trang bng m (shadow pages).
e. kin khc.

Cu 38. iu g NG vi giao thc ghi log trc
(write ahead logging WAL)?
a. Vic cp nht d liu nn c thc hin trc tc
v ghi log.
b. Bn ghi log cho mt tc v cp nht nn c ghi
log trc khi d liu tht s c ghi.
c. T c cc bn ghi log nn c ghi log trc khi
mt giao tc mi bt u thc thi.
d. S ghi log khng bao gi cn c ghi xung a.
e. kin khc.

Cu 39. m bo vic phc hi d liu lun ng,
cc tc v REDO cn c c im g?
a. Hon v ln nhau (commutative)
b. Kt hp ln nhau (associative)
c. Khng thay i gi tr (idempotent)
d. Phn tn (distributive)
e. kin khc.


11

Cu 40. Chn pht biu NG v cc tc v bo tr
tnh nguyn t (atomicity) ca giao tc trong qu
trnh phc hi d liu.
a. UNDO l tc v tho g bng cch loi b BFI M
khi c s d liu trn a v REDO l tc v ti
thc hin bng cch phc hi li AFI M n c s d
liu trn a.
b. UNDO l tc v tho g bng cch loi b AFI M
khi c s d liu trn a v REDO l tc v ti
thc hin bng cch phc hi li BFI M n c s d
liu trn a.
c. UNDO l tc v tho g bng cch loi b BFI M
khi c s d liu trn a v REDO l tc v ti
thc hin bng cch phc hi li BFI M n c s d
liu trn a.
d. UNDO l tc v tho g bng cch loi b AFI M
khi c s d liu trn a v REDO l tc v ti
thc hin bng cch phc hi li AFI M n c s d
liu trn a.
e. kin khc.

Cu 41. Gii thut phc hi ARI ES dng cch tip
cn no ghi d liu xung c s d liu trn a?
a. Steal/Force
b. Steal/No-Force
c. No-Steal/No-Force
d. No-Steal/Force
e. kin khc.

Cu 42. Shadow paging l dng k thut phc hi g?
a. UNDO/REDO
b. NO-UNDO/REDO
c. NO-UNDO/NO-REDO
d. UNDO/NO-REDO
e. kin khc.

Cu 43. Cho lch biu S16 ca cc giao tc thc thi
trong mi trng a ngi dng trong Hnh 7. Xc
nh ni dung ca s ghi h thng (system log) ti
im thi gian 9:30 khi k thut phc hi dng cp
nht tr hon (deferred update) c s dng.
a. [start_transaction, T1]
[read_item, T1, A]
[write_item, T1, A, 15]
[commit, T1]

b. [start_transaction, T1]
[read_item, T1, A]
[start_transaction, T2]
[read_item, T2, A]
[write_item, T1, A, 15]
[commit, T1]
[checkpoint]
[start_transaction, T3]
[write_item, T3, B, 20]
[read_item, T3, B]
[system_crash]
[undo, T3, B, 20]

c. [start_transaction, T1]
[read_item, T1, A]
[start_transaction, T2]
[read_item, T2, A]
[write_item, T1, A, 15]
[commit, T1]
[checkpoint]
[start_transaction, T3]
[write_item, T3, B, 20]
[read_item, T3, B]

d. [start_transaction, T1]
[start_transaction, T2]
[write_item, T1, A, 15]
[commit, T1]
[checkpoint]
[start_transaction, T3]
[write_item, T3, B, 20]

e. kin khc.

Cu 44. Cho lch biu S17 ca cc giao tc thc thi
trong mi trng a ngi dng trong Hnh 8. Chn
pht biu SAI v vic phc hi d liu khi h thng
ngng thc thi ti im thi gian 9:30 vi k thut
phc hi dng cp nht tr hon (deferred update).


12
a. Cc tc v ghi ca giao tc T1 khng cn ti thc
hin do T1 commit trc checkpoint.
b. Cc tc v ghi ca giao tc T2 cn ti thc hin do
T2 commit sau checkpoint nhng trc 9:30.
c. Cc tc v ghi ca giao tc T3 cn c tho g do
T3 bt u trc checkpoint nhng cha t im
commit trc 9:30.
d. Cc tc v ghi ca giao tc T4 c b qua do T4
bt u sau checkpoint nhng cha t im commit
trc 9:30.
e. kin khc.

Cu 45. Cho ni dung ca s ghi h thng ti im
thi gian 9:30 khi h thng b ngng thc thi (system
crash) trong Bng 2 v ni dung ca cc bng
Transaction v Dirty Page ti im checkpoint trong
Bng 3. Xc nh ni dung ca cc bng Transaction
v Dirty Page sau giai on phn tch (analysis
phase) ca k thut phc hi ARIES.
a. Bng 4
b. Bng 5
c. Bng 6
d. Bng 7
e. kin khc.



Hnh 1 Cy ch mc B-tree c bc p = 3 c to trn vng tin kha ID (Cu 7.a)


Hnh 2 Cy ch mc B-tree c bc p = 3 c to trn vng tin kha ID (Cu 7.b)

Hnh 3 Cy ch mc B-tree c bc p = 3 c to trn vng tin kha ID (Cu 7.c)


13

Hnh 4 Cy ch mc B-tree c bc p = 3 c to trn vng tin kha ID (Cu 7.d)

Hnh 5 Cy ch mc B+-tree c bc p = 3 v pleaf = 2 (Cu 9, 10, v 11)


Hnh 6 Phn cp d liu (Cu 36)

Hnh 7 Lch biu S16 ca cc giao tc thc thi trong mi trng a ngi dng vi k thut phc hi dng cp
nht tr hon (Cu 43)



14

Hnh 8 Lch biu S17 ca cc giao tc thc thi trong mi trng a ngi dng (Cu 44)

Bng 1 Lch biu S15 vi k thut iu khin tng tranh a phin bn dng sp th t theo nhn thi gian
(Cu 32)
T1 T2 T3 A0 A150 A200
TS=150 TS=200 TS=175 Read_TS=0;
Write_TS=0
Read_TS=150;
Write_TS=150
Read_TS=200;
Write_TS=200
r
1
(A) Read_TS=150
w
1
(A) Created
r
2
(A) Read_TS=200
w
2
(A) Created
r
3
(A)

Bng 2 S ghi h thng khi h thng b ngng thc thi (Cu 45)
LSN LAST_LSN TRAN_ID TYPE PAGE_ID
1 0 T1 update C
2 1 T1 update B
3 0 T2 update C
4 begin_checkpoint
5 end_checkpoint
6 2 T1 commit
7 0 T3 update A

Bng 3 Bng Transaction v Dirty Page ti thi im checkpoint (Cu 45)
TRANSACTION TABLE DIRTY PAGE TABLE
TRANSACTION ID LAST LSN STATUS PAGE ID LSN
T1 2 in progress C 1
T2 3 in progress B 2

Bng 4 Bng Transaction v Dirty Page sau giai on phn tch (Cu 45.a)
TRANSACTION TABLE DIRTY PAGE TABLE
TRANSACTION ID LAST LSN STATUS PAGE ID LSN
T1 6 Commit C 1
T2 3 in progress B 2
T3 7 in progress A 7


15

Bng 5 Bng Transaction v Dirty Page sau giai on phn tch (Cu 45.b)
TRANSACTION TABLE DIRTY PAGE TABLE
TRANSACTION ID LAST LSN STATUS PAGE ID LSN
T1 6 commit C 3
T2 3 in progress B 2
T3 7 in progress A 7

Bng 6 Bng Transaction v Dirty Page sau giai on phn tch (Cu 45.c)
TRANSACTION TABLE DIRTY PAGE TABLE
TRANSACTION ID LAST LSN STATUS PAGE ID LSN
T1 6 commit C 1, 3
T2 3 in progress B 2
T3 7 in progress A 7

Bng 7 Bng Transaction v Dirty Page sau giai on phn tch (Cu 45.d)
TRANSACTION TABLE DIRTY PAGE TABLE
TRANSACTION ID LAST LSN STATUS PAGE ID LSN
T1 6 commit A 7

H - Tn: .
M S Sinh Vin:


Mn: H Qun Tr C S D Liu (503004)
Hc k 2 - 2011-2012
Ngy thi: 13/06/2012
Phng thi: ............................
M : 01
16
Phn tr li:


Cu 1 - 15:
Cu 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
a
b
c
d
e


Cu 16 - 30:
Cu 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
a
b
c
d
e


Cu 31 - 45:
Cu 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
a
b
c
d
e

Phn gii thch p n (e) nu c:

You might also like