CONCURENCY CONTROL DISTRIBUTED DATABASE
M AIN TOPICS Transaction managements Centralized database Distributed database Consistency control Centralized database Distributed database
D ATABASE C ONSISTENCY Setiap data yang disimpan ke dalam database harus konsisten Dikatakan konsisten jika data yang dimasukkan ke dalam database, sesuai dengan kriteria Misal: SSN (social security number harus mempunyai nilai unik) Umur harus mempunyai nilai positif Employee harus bekerja pada satu departemen Saldo dalam rekening harus mempunyai nilai positif
T RANSACTION Transaksi merupakan kumpulan dari operasi yang dilakukan pada sebuah data Suatu transaksi harus mempunyai sifat ACID (Atomicity, Consistency, Isolation, Durability)
T RANSACTION ( CONT ’ D ) Suatu transaksi di dalam database yang utama adalah proses Read dan Write Setiap transaksi berisi sekumpulan operasi yang terurut Pada multi-user transaction processing terdapat banyak transaksi yang dijalankan dalam sekali waktu, dan bisa jadi operasi-operasi yang dilakukan saling tumpang tindih
ACID Atomicity – all of the operation of transaction are carried out or none of them are carried out. Consistency – property of transaction requires a transaction to be written correctly Isolation – property of transaction requires that transaction to be run out without interference from other transaction – can be achieve by locking or timestamping Durability – property of a transaction requires the value that the transaction commit to the database persistent.
T RANSACTION LIFE CYCLE
M ULTITRANSACTION PROCESSING SYSTEM Schedule Conflict Equivalence Serializable Schedule
S CHEDULING Schedule is a the total order of operations or set of transactions. Scheduling type Serial Schedule – the operations for each transaction do not overlap in time Parallel Schedule – the operations for each transaction do overlap in time
S ERIAL AND PARALLEL SCHEDULE
S ERIES TRANSACTION Two or more transactions running in series maintain the consistency of database
C ONFLICTS Conflicts occurs when two running transactions perform noncompatible operations on the same data item of the database
C ONFLICTS ( CONT ’ D ) Each of that schedule produce some anomalies Unrepeatable read anomaly (in-S1) Reading uncommitted data / dirty read anomaly (in S2) Overwriting uncommitted data anomaly (in S2)
E QUIVALENCE The problems Concurrent transactions can cause anomaly – the anomaly can destroy consistency of database Solution Run all transaction in series Run transaction concurrently Goal Preserve the consistency of database If the 2nd solution can achieve the goal – Equivalence
E QUIVALENCE TRANSACTION Example:
S ERIALIZABLE S CHEDULE A schedule is said to be serializable if it equivalent to serrial schedule The check for serial schedule equivalence - serializability. The T1 transaction (R1, W1) must be committed, before T2 transaction (R2, W2) being executed
S ERIALIZABLE EXAMPLE