You are on page 1of 19

CS2323-Sistem Berkas & Basis

Data

Pertemuan 5 :
File Sekuensial

1
Sequential (Ordered) File

ID Company Industry Symbl. Price Earns. Dividnd.


1122 Exxon Oil XON 46.00 2.50 0.75
1152 Lockheed Aero LCH 112.00 1.25 0.50
1175 Ford Auto F 88.00 1.70 0.20
1231 Intel Comp. INTL 30.00 2.00 0.00
1245 Digital Comp. DEC 120.00 1.80 0.10
1323 GM Auto GM 158.00 2.10 0.30
1378 Texaco Oil TX 230.00 2.80 1.00
1480 Conoco Oil CON 150.00 2.00 0.50
1767 Tony Lama Apparel TONY 45.00 1.50 0.25
Sequential Access

1231...

1175...
1152 ...
1122...other data
File Sekuensial

 Adanya keberurutan rekord-rekord di file


menurut kriteria tertentu  ordered file
 Karakteristik :
– Rekord berisi semua nilai data atribut dengan
posisi yang sama
– Adanya aturan/kriteria tertentu yang menjadi
kunci pengurutan data. Kunci bersifat unik

4
Sequential File Characteristics

 Older media (cards, tapes)


 Records physically ordered by primary key
 Use when direct access to individual records is
not required
 Accessing records
– Sequential search until record is found
 Binary search can speed up access
– Must know file size and how to determine mid-point,
File Sekuensial

 Nama atribut tidak perlu ditulis di tiap rekord,


tapi muncul pada file header.
 Dengan adanya konstrain sekuens dan
rekord tetap maka terjadi peningkatan
effesiensi, tapi ada penurunan fleksibilitas.
 Rekord-rekord harus dijaga berdasar atribut
kunci

6
File Sekuensial

 Penyisipan dilakukan di akhir file atau di slot kosong


akibat penghapusan record
 Penyisipan dilakukan dengan menggunakan file
transaction log. Jika ukuran file log sudah cukup
besar, maka dilakukan reorganisasi.
 Secara periodik dilakukan merge antara file log dan
file utama/master file
 Komponen :
– File Utama
– File Transaction Log  berupa struktur Pile

7
Inserting Records in SAM files

 Insertion
– Slow:
 Sequential search to find where the record goes
 If sufficient space in that page, then rewrite
 If insufficient space, move some records to next page
 If no space there, keep bumping down until space is
found
– May use an “overflow” file to decrease time

8
Deletions and Updates to SAM

 Deletion
– Slow:
 Find the record
 Either mark for deletion or free up the space
 Rewrite
 Updates
– Slow:
 Find the record
 Make the change
 Rewrite
9
Interesting problems:

 How much free space to leave in each block,


track, cylinder?
 How often do I reorganize file + overflow?

10
Performansi File Sekuensial

 R=aV
a : jumlah atribut pada satu rekord
V : Panjang rata-rata nilai atribut (byte)
 Fetch Rekord (TF)
– Pencarian menggunakan atribut bukan kunci
 Belum ada File Log  rata-rata, ½ file akan ditelusuri
TF = ½ waktu pencarian seluruh blok
= ½ b. B/t’ = ½. n R/t’
 Sudah ada file Log
TFo = ½. o’ R/t’
TF = ½ (n + o) R/t’

11
– Pencarian menggunakan atribut kunci (pencarian
biner)
 Belum terbentuk log
TF = 2log (b) (s + r + btt + c)
= 2log (n/Bfr) (s + r + btt+ c)
 Sudah terbentuk log
TF = 2log (n/Bfr) (s + r + btt+ c) + ½ o (R/t’)

12
 TN = waktu transfer 1 blok x peluang ditemukannya
rekord dalam blok yang sama
= btt . 1/Bfr = R/t

 Waktu Penyisipan rekord baru


– Cari, geser, sisip
TI = TF + ½ (n/Bfr) (btt + T RW)
– Memakai log file
TI = s + r + TRW + (TY/o)

13
 Waktu Update
– Bukan kunci
TU = TF + TRW
– Terhadap Kunci : find rekord, hapus rekord,
sisipkan rekord
TU = TF(main) + TI (file log)

14
 Waktu Pembacaan Seluruh Rekord (Tx)
Tx = Tsort(o) + (n+o) R/t’

 Waktu Reorganisasi File (Ty)


Ty = Tsort (o) + nold(R/t’) + o(R/t’) + nnew(R/t’)
= Tsort (o) + 2(n+o)(R/t’)

15
Latihan
Diketahui File sekuensial :
- Putaran disk = 8000 rpm
- Seek time = 5 ms
- Transfer rate = 2048 byte/ms
- TRW = 2r
- Ukuran blok = 4096 byte
- Ukuran Pointer blok = 8 byte
- IBG = 1024 byte
- Jumlah rekord di file = 100000 rekord
- Jumlah field = 8 field
- Panjang nilai = 25 byte
- Jumlah rekord file log = 5000 rekord
- Waktu pemrosesan = 2 ms

16
Hitung :
R, TF, TN, TI, TU, Tx, Ty jika metode bloking :
1. Fixed
2. Variable length Spanned
3. Variable length Unspanned

17
Pembahasan

 Metode Fixed Blocking


- R = aV = 8.25 = 200 byte
- TF = ½ n R/t’
cari dulu t’, t’ = (t/2)(R/R+W)
cari dulu W, pada fixed Blocking W = G/Bfr
cari Bfr, Bfr = B/R = 4096 / 200 = 20.48 = 20
Maka W = G/Bfr = 1024/20 = 51.2 byte

18
Pembahasan
t’ = (t/2)(R/R+W)
= (2048/2)(200/200+51.2) = 1024.(0.796)
= 815.10 ms

TF = ½ n R/t’
= ½ (100000)(200/815.10) = 50000(0.245) =
= 12268.43 ms = 12.26843 s

TN = btt/Bfr
Cari btt  btt = B/t = 4096 / 2048 = 2 ms
TN = 2/20 = 0.1 ms

Kerjakan sisa soal sebagai latihan !

19

You might also like