PENGANTAR MANAJEMEN BASIS DATA
Transcription
PENGANTAR MANAJEMEN BASIS DATA
PENGANTAR MANAJEMEN BASIS DATA 1 Pengenalan Database Konsep dasar database, DBMS • Basis data menyediakan fasilitas atau mempermudah dalam menghasilkan informasi yang digunakan oleh pemakai untuk mendukung pengambilan keputusan • contoh penggunaan Aplikasi basis data dalam dunia bisnis : ……? Sistem Pemrosesan Berkas Tradisional • Bentuk pemrosesan dasar yang lahir sebelum database muncul • Berkecunderungan tidak berbagi berkas (Setiap aplikasi memiliki berkas tersendiri) Aplikasi Personalia Personalia Aplikasi Pelatihan Pelatihan Kelemahannya dari sistem pemrosesan berkas tradisional 1. Timbulnya data rangkap (redundancy data) dan Ketidakkonsistensi data (Inconsistency data) 2. Kesukaran dalam Mengakses Data 3. Data terisolir (Isolation Data) 4. Masalah Pengamanan ( Security Problem ) 5. Data Dependence Sistem Basis data • Seiring dengan berjalannya waktu, lambat laun sistem pemrosesan file mulai ditinggalkan karena masih bersifat manual, yang kemudian dikembangkanlah sistem pemrosesan dengan pendekatan basis data. GAMBAR MENJADI SPT APA? Definisi Database • “a collection of related data” (Elmazri & Navathe, 1994) • “an organized collection of logically related data” (McFadden, Hoffer, and Presscot, 2002) • “a collection of data, typically describing the activities of one or more related organizations” (Ramakrishnan & Gerke, 2000) Data dan Basis Data • Data adalah representasi fakta dunia nyata yang mewakili suatu objek seperti manusia (pegawai, mahasiswa, pembeli), barang, hewan, peristiwa, konsep, keadaan, dan sebagainya yang direkam dalam bentu angka, huruf, simbol, teks, gambar, bunyi atau kombinasinya. • Basis Data adalah sekumpulan data yang terintegrasi yang diorganisasikan untuk memenuhi kebutuhan para pemakai di dalam suatu organisasi. • DBMS (Database Management System) adalah Perangkat Lunak yang menangani semua pengaksesan ke basis data • Sistem Basis Data terdiri dari basis data dan DBMS Istilah - Istilah Dasar Basis Data • Enterprise • Bentuk organisasi :………? • Data operasional : ……….? • Entitas • Contoh Entitas • Atribut (Elemen Data) • Nilai Data (Data Value) • Kunci Elemen Data (Key Data Element) • Record Data Pengguna Basis Data • 1. System Engineer • 2. Database Administrator (DBA) • 3. End User (Pemakai Akhir) – a. Programmer aplikasi – b. Pemakai Mahir (Casual User) – c. Pemakai Umum (End User / Naïve User) – d. Pemakai Khusus (Specialized/ Sophisticated User) 11 12 13 DBA SKILLS 14 15 16 17 Levels of Abstraction • Many views, single conceptual (logical) schema and physical schema. – – – Views describe how users see the data. Conceptual schema defines logical structure Physical schema describes the files and indexes used. View 1 View 2 View 3 Conceptual Schema Physical Schema ☛ Schemas are defined using DDL; data is modified/queried using DML. Example: University Database • Conceptual schema: – Students(sid: string, name: string, login: string, age: integer, gpa:real) – Courses(cid: string, cname:string, credits:integer) – Enrolled(sid:string, cid:string, grade:string) • Physical schema: – Relations stored as unordered files. – Index on first column of Students. • External Schema (View): – Course_info(cid:string,enrollment:integer) Application Programs Queries Database Schema DML Preprocessor Query Processor DDL Compiler Programs Object Code Database Manager Dictionary Manager Access Method File Manager DBMS (Database Management System) System Buffer Database dan Data Dic4onary Komponen DBMS 20 Contoh-contoh Basis Data Relasional : • • • • • • DB2 à IBM ORACLE à Oracle SYBASE à Powersoft INFORMIX à Informix Microsoft Access à Microsoft MySQL 21 Concurrency Control • Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are frequent, and relatively slow, it is important to keep the cpu humming by working on several user programs concurrently. • Interleaving actions of different user programs can lead to inconsistency: e.g., check is cleared while account balance is being computed. • DBMS ensures such problems don’t arise: users can pretend they are using a single-user system. Concurrency Control • Concurrency control ensures that one user’s work does not inappropriately influence another user’s work – No single concurrency control technique is ideal for all circumstances – Trade-offs need to be made between level of protection and throughput Atomic Transactions • A transaction, or logical unit of work (LUW), is a series of actions taken against the database that occurs as an atomic unit – Either all actions in a transaction occur or none of them do Example: Atomic Transaction Example: Atomic Transaction Concurrent Transaction • Concurrent transactions refer to two or more transactions that appear to users as they are being processed against a database at the same time • In reality, CPU can execute only one instruction at a time – Transactions are interleaved meaning that the operating system quickly switches CPU services among tasks so that some portion of each of them is carried out in a given interval • Concurrency problems: lost update and inconsistent reads Example: Concurrent Transactions Example: Lost Update Problem Resource Locking • Resource locking prevents multiple applications from obtaining copies of the same record when the record is about to be changed Lock Terminology • Implicit locks are locks placed by the DBMS • Explicit locks are issued by the application program • Lock granularity refers to size of a locked resource – Rows, page, table, and database level – Large granularity is easy to manage but frequently causes conflicts • Types of lock – An exclusive lock prohibits other users from reading the locked resource – A shared lock allows other users to read the locked resource, but they cannot update it Example: Explicit Locks Deadlock • Deadlock, or the deadly embrace, occurs when two transactions are each waiting on a resource that the other transaction holds Example: Deadlock Deadlock • Preventing deadlock – Allow users to issue all lock requests at one time – Require all application programs to lock resources in the same order • Breaking deadlock – Almost every DBMS has algorithms for detecting deadlock – When deadlock occurs, DBMS aborts one of the transactions and rollbacks partially completed work Declaring Lock Characteristics • Most application programs do not explicitly declare locks due to its complication • Instead, they mark transaction boundaries and declare locking behavior they want the DBMS to use – Transaction boundary markers: BEGIN, COMMIT, and ROLLBACK TRANSACTION • Advantage – If the locking behavior needs to be changed, only the lock declaration need be changed, not the application program Example: Marking Transaction Boundaries Database Security • Database security ensures that only authorized users can perform authorized activities at authorized times • Developing database security – Determine users’ processing rights and responsibilities – Enforce security requirements using security features from both DBMS and application programs DBMS Security • DBMS products provide security facilities • They limit certain actions on certain objects to certain users or groups • Almost all DBMS products use some form of user name and password security DBMS Security Model DBMS Security Guidelines • Run DBMS behind a firewall, but plan as though the firewall has been breached • Apply the latest operating system and DBMS service packs and fixes • Use the least functionality possible – – – – Support the fewest network protocols possible Delete unnecessary or unused system stored procedures Disable default logins and guest users, if possible Unless required, never allow all users to log on to the DBMS interactively • Protect the computer that runs the DBMS – No user allowed to work at the computer that runs the DBMS – DBMS computer physically secured behind locked doors – Access to the room containing the DBMS computer should be recorded in a log • DBMS Security Guidelines (cont.) Manage accounts and passwords – – – – – – – Use a low privilege user account for the DBMS service Protect database accounts with strong passwords Monitor failed login attempts Frequently check group and role memberships Audit accounts with null passwords Assign accounts the lowest privileges possible Limit DBA account privileges • Planning – Develop a security plan for preventing and detecting security problems – Create procedures for security emergencies and practice them Application Security • If DBMS security features are inadequate, additional security code could be written in application program – Application security in Internet applications is often provided on the Web server computer • However, you should use the DBMS security features first – The closer the security enforcement is to the data, the less chance there is for infiltration – DBMS security features are faster, cheaper, and probably result in higher quality results than developing your own Database Recovery • In the event of system failure, that database must be restored to a usable state as soon as possible • Two recovery techniques: – Recovery via reprocessing – Recovery via rollback/rollforward Recovery via Reprocessing • Recovery via reprocessing: the database goes back to a known point (database save) and reprocesses the workload from there (re-execute all database update programs) • Unfeasible strategy because – The recovered system may never catch up if the computer is heavily scheduled – Asynchronous events, although concurrent transactions, may cause different results Rollback/Rollforward • Recovery via rollback/rollforward: – Periodically save the database and keep a database change log since the save • Database log contains records of the data changes in chronological order • When there is a failure, either rollback or rollforward is applied – Rollback: undo the erroneous changes made to the database and reprocess valid transactions – Rollforward: restored database using saved data and valid transactions since the last save Example: Rollback • Before-images: a copy of every database record (or page) before it was changed Example: Rollforward • After-images: a copy of every database record (or page) after it was changed Example: Transaction Log Checkpoint • A checkpoint is a point of synchronization between the database and the transaction log – DBMS refuses new requests, finishes processing outstanding requests, and writes its buffers to disk – The DBMS waits until the writing is successfully completed à the log and the database are synchronized • Checkpoints speed up database recovery process – Database can be recovered using after-images since the last checkpoint – Checkpoint can be done several times per hour • Most DBMS products automatically checkpoint themselves Overview of System Architecture Database Server Database Cache read write begin Database Page commit, rollback write Volatile Memory Stable Storage Stable Database fetch Database Page flush Log Buffer Log Entry force Stable Log Log Entry Databases make these folks happy ... • End users and DBMS vendors • DB application programmers – E.g. smart webmasters • Database administrator (DBA) Designs logical /physical schemas – Handles security and authorization – Data availability, crash recovery – Database tuning as needs evolve – Must understand how a DBMS works! Structure of a DBMS • A typical DBMS has a layered architecture. • The figure does not show the concurrency control and recovery components. • This is one of several possible architectures; each system has its own variations. These layers must consider concurrency control and recovery Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB 54 TUGAS 1. Tugas per kelompok, 1 kelompok : …mhs 2. Per kelompok tentukan contoh kasus suatu sistem informasi atau aplikasi bebas yang digunakan pada satu organisasi. Misal : Aplikasi ATM Contoh kasus tidak harus seluruh sistem atau aplikasi, satu subsistem atau satu modul saja. 55 3. Dari contoh kasus yang sudah ditentukan buat Rancangan Database dan Implementasi nya secara sederhana. Rancangan database dapat menggunakan alat bantu ERD atau Class Diagram 4. Aplikasi sederhana, buat tampilan input dan output yang merepresentasi rancangan database yang telah dibuat. 56 Contoh : • Aplikasi ATM untuk Modul Informasi Saldo • Rancangan Database 57 • Form Input 58 • OUTPUT Nomor Rekening : …. Nama : …. Saldo : X.XXX.XXX 59 FORMAT PRESENTASI • • • • • NAMA SISTEM INFORMASI GAMBARAN UMUM SISTEM INFORMASI SUB SISTEM RANCANGAN DATABASE APLIKASI SEDERHANA à LANGSUNG KE PROGRAM – INPUT – OUTPUT 60