19

Click here to load reader

sekuensial

Embed Size (px)

Citation preview

Page 1: sekuensial

1

CS2323-Sistem Berkas & Basis Data

Pertemuan 5 :File Sekuensial

Page 2: sekuensial

Sequential (Ordered) File

ID Company Industry Symbl. Price Earns. Dividnd.1122 Exxon Oil XON 46.00 2.50 0.751152 Lockheed Aero LCH 112.00 1.25 0.501175 Ford Auto F 88.00 1.70 0.201231 Intel Comp. INTL 30.00 2.00 0.001245 Digital Comp. DEC 120.00 1.80 0.101323 GM Auto GM 158.00 2.10 0.301378 Texaco Oil TX 230.00 2.80 1.001480 Conoco Oil CON 150.00 2.00 0.501767 Tony Lama Apparel TONY 45.00 1.50 0.25

Page 3: sekuensial

Sequential Access

1122...other data

1152 ...

1175...

1231...

Page 4: sekuensial

4

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

Page 5: sekuensial

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,

Page 6: sekuensial

6

File Sekuensial

� Nama atribut tidak perlu ditulis di tiap rekord, tapi muncul pada file header.

� Dengan adanya konstrain sekuens danrekord tetap maka terjadi peningkataneffesiensi, tapi ada penurunan fleksibilitas.

� Rekord-rekord harus dijaga berdasar atributkunci

Page 7: sekuensial

7

File Sekuensial

� Penyisipan dilakukan di akhir file atau di slot kosongakibat penghapusan record

� Penyisipan dilakukan dengan menggunakan file transaction log. Jika ukuran file log sudah cukupbesar, maka dilakukan reorganisasi.

� Secara periodik dilakukan merge antara file log danfile utama/master file

� Komponen :– File Utama– File Transaction Log � berupa struktur Pile

Page 8: sekuensial

8

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

Page 9: sekuensial

9

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

Page 10: sekuensial

10

Interesting problems:

� How much free space to leave in each block, track, cylinder?

� How often do I reorganize file + overflow?

Page 11: sekuensial

11

Performansi File Sekuensial

� R = a Va : jumlah atribut pada satu rekordV : Panjang rata-rata nilai atribut (byte)

� Fetch Rekord (TF)– Pencarian menggunakan atribut bukan kunci

� Belum ada File Log � rata-rata, ½ file akan ditelusuriTF = ½ waktu pencarian seluruh blok

= ½ b. B/t’ = ½. n R/t’� Sudah ada file Log

TFo = ½. o’ R/t’TF = ½ (n + o) R/t’

Page 12: sekuensial

12

– Pencarian menggunakan atribut kunci (pencarianbiner)� 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’)

Page 13: sekuensial

13

� TN = waktu transfer 1 blok x peluang ditemukannyarekord dalam blok yang sama

= btt . 1/Bfr = R/t

� Waktu Penyisipan rekord baru– Cari, geser, sisip

TI = TF + ½ (n/Bfr) (btt + TRW)

– Memakai log fileTI = s + r + TRW + (TY/o)

Page 14: sekuensial

14

� Waktu Update– Bukan kunci

TU = TF + TRW

– Terhadap Kunci : find rekord, hapus rekord, sisipkan rekord

TU = TF(main) + TI (file log)

Page 15: sekuensial

15

� 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’)

Page 16: sekuensial

16

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

Page 17: sekuensial

17

Hitung :

R, TF, TN, TI, TU, Tx, Ty jika metode bloking :1. Fixed

2. Variable length Spanned3. Variable length Unspanned

Page 18: sekuensial

18

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 = 20Maka W = G/Bfr = 1024/20 = 51.2 byte

Page 19: sekuensial

19

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/BfrCari btt � btt = B/t = 4096 / 2048 = 2 msTN = 2/20 = 0.1 ms

Kerjakan sisa soal sebagai latihan !