You are on page 1of 29

CSH2D3/ Sequential File

TEAM DOSEN SBD GENAP 2017/2018


Sequential File
File is ordered according to a specific criteria
Characteristic
– Attributes are located in the same position
– Has KEY to sort the data
– Has HEADER to indicate attribute names
– Each record must maintain the key. No keys violations are
allowed
– Efficient in retrieval process
Data structure
Main file
Transaction Log  Pile
Insertion/ Update / Delete
Using transaction log log needs to be
reorganized
INSERT
UPDATE
DELETE
Sequential File Performance
R=aV
a : #of attributes
V : Average attribute length (byte)

Record Fetch(TF)
– Sequential Search
– Binary Search
– Probing Search

8
Sequential Search

 File Log unavailable on the average, ½ of file will be read


TF = ½ block time search
= ½ b (B/t’) = ½ n (R/t’)
 File log available
TFo = ½. o (R/t’)
TF = ½ (n + o) R/t’
Binary Search

 Without Log
TF = 2log (b) (s + r + btt + c)
= 2log (n/Bfr) (s + r + btt+ c)
 With log
TF = 2log (b) (s + r + btt+ c) + ½ o (R/t’)
= 2log (n/Bfr) (s + r + btt+ c) + ½ o (R/t’)

10
Probing Search
Guess the record position in the file
Do the sequential search from the guessed
position
Notes:
The probing based on probability score
Hard to estimates searching time
Time to Fetch Successor Record (TN)
TN = time to transfer 1 block x probability to find
the record in the same block
= btt . 1/Bfr
= btt/Bfr
= R/t

12
Exercises
Create Sequential File with the following data:
– 2,4,5,9,3,6,1,7,12,8,11

Update the following data:


– 3  15
–2  3
–7  2

Delete the following data:


– 11
–2
Indexed Sequential Files

CS2323 / 6-File Sekuensial Berindeks - RIE

23
Indexed sequential files
Add a single index for sequential file to enhance
searching process based on index attribute.
Can be used for directed access or indexed access

24
Data Structure

Components:
–Main/Primary File
–Index
Overflow

–Overflow Area Index Main File

CS2323 / 6-File Sekuensial Berindeks - RIE


25
Example

26
Index for Indexed-Sequential File
Indexed file is static, multilevel, block anchors
(+)index : Faster block retrieval
Indexed entry is sorted
For n records, #of entry indexes= n/Bfr
Entry size : V+P byte (V=Key, P = TID Pointer)

27
Index Parameter

Fanout Ratio : Ratio between block size B


with space needed to store an index entry
 B 
y
V  P 

Height : # of index level

x   y log n / Bfr  x  ln n / Bfr  / ln y 


CS2323 / 6-File Sekuensial Berindeks - RIE
28
Index Parameter
Example :
Let,
B = 2000 byte
V = 14 byte
TID size Pointer = 6 byte
R = 200 byte.
Find fanout ratio y and index level x ?

29
Overflow Area
Unoccupied, separated area to store new record
Push-Through Algorithm :
– New record is inserted in proper position
– Next record is always inserted at the end of block
– If block is full, push to overflow area

30
Example

Kondisi Awal Insert 075 Insert 129 Insert 676 Insert 063 Insert 156

013-... 013-... 013-... 013-... 013-... 013-...


028-... 028-... 028-... 028-... 028-... 028-...
128-... 075-... 075-... 075-... 063-... 063-...

134-... 134-... 134-... 134-... 134-... 134-...


143-... 143-... 143-... 143-... 143-... 143-...

Main File
Main File

Main File
Main File

Main File
Main File
151-... 151-... 151-... 151-... 151-... 151-...

616-... 616-... 616-... 616-... 616-... 616-...


633-... 633-... 633-... 633-... 633-... 633-...
704-... 704-... 704-... 676-... 676-... 676-...

711-... 711-... 711-... 711-... 711-... 711-...


743-... 743-... 743-... 743-... 743-... 743-...
896-... 896-... 896-... 896-... 896-... 896-...

128-...

Overflow Area
128-...
Overflow Area

128-... 128-...
Overflow Area

128-...
Overflow Area

Overflow Area
Overflow Area

129-... 129-... 129-... 129-...


704-... 704-... 704-...

075-... 075-...
156-...

31
The Result

32
Indexed File Performance
Record Size
R = aV+P
a : #of attribute
V : average attribute length
P : additional tombstone size field
# of records for indexed sequential file
n = n m + no
nm : #of records in main file
no : #of records in overflow area

33
Indexed Sequential File Performance
#of first level index entry (i1)
il = nm / Bfr
#of index entry on the next level :

#of block needed at a level :

CS2323 / 6-File Sekuensial Berindeks - RIE


34
Reorganization time (TY)

Do reorganization if:
–Overflow area is not empty
–Overflow area is long
–Fetching time is long
Reorganization process

–Read sequentially
–Rewrite all record, except marked for delete
records
–Create index for each block
–Delete old file and index

43
References
Hariyanto, Bambang. “Sistem Pengarsipan dan
Metode Akses”, Bandung: Penerbit Informatika.
2003
Weiderhold, Gio, “File Organization for Database
Design”, New York: McGraaw-Hill Book Co., 1987.
THANK YOU

You might also like