PENGANTAR MANAJEMEN BASIS DATA

60
PENGANTAR MANAJEMEN BASIS DATA 1

Transcript of PENGANTAR MANAJEMEN BASIS DATA

Page 1: PENGANTAR MANAJEMEN BASIS DATA

PENGANTAR MANAJEMEN BASIS DATA

1

Page 2: PENGANTAR MANAJEMEN BASIS DATA

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 : ……?

Page 3: PENGANTAR MANAJEMEN BASIS DATA

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

Page 4: PENGANTAR MANAJEMEN BASIS DATA

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

Page 5: PENGANTAR MANAJEMEN BASIS DATA

Sistem Basis data •  Seiring dengan berjalannya waktu, lambat

laun sistem pemrosesan file mulai dit inggalkan karena masih bersifat manual, yang kemudian dikembangkanlah sistem pemrosesan dengan pendekatan basis data.

GAMBAR MENJADI SPT APA?

Page 6: PENGANTAR MANAJEMEN BASIS DATA

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)

Page 7: PENGANTAR MANAJEMEN BASIS DATA

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.

Page 8: PENGANTAR MANAJEMEN BASIS DATA

•  DBMS (Database Management System) adalah Perangkat Lunak yang menangani semua pengaksesan ke basis data

•  Sistem Basis Data terdiri dari basis data dan DBMS

Page 9: PENGANTAR MANAJEMEN BASIS DATA

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

Page 10: PENGANTAR MANAJEMEN BASIS 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)

Page 11: PENGANTAR MANAJEMEN BASIS DATA

11

Page 12: PENGANTAR MANAJEMEN BASIS DATA

12

Page 13: PENGANTAR MANAJEMEN BASIS DATA

13

Page 14: PENGANTAR MANAJEMEN BASIS DATA

14

DBA SKILLS

Page 15: PENGANTAR MANAJEMEN BASIS DATA

15

Page 16: PENGANTAR MANAJEMEN BASIS DATA

16

Page 17: PENGANTAR MANAJEMEN BASIS DATA

17

Page 18: PENGANTAR MANAJEMEN BASIS DATA

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.

☛  Schemas are defined using DDL; data is modified/queried using DML.

Physical Schema

Conceptual Schema

View 1 View 2 View 3

Page 19: PENGANTAR MANAJEMEN BASIS DATA

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)

Page 20: PENGANTAR MANAJEMEN BASIS DATA

20

DBMS  (Database  Management  System)

Application Programs Queries Database Schema

DML Preprocessor Query Processor DDL Compiler

Programs Object Code Database Manager Dictionary Manager

Access Method

File Manager

System Buffer

Database  dan  Data  Dic4onary

Komponen DBMS

Page 21: PENGANTAR MANAJEMEN BASIS DATA

Contoh-contoh Basis Data

Relasional : •  DB2 à IBM

•  ORACLE à Oracle •  SYBASE à Powersoft •  INFORMIX à Informix •  Microsoft Access à Microsoft •  MySQL

21

Page 22: PENGANTAR MANAJEMEN BASIS DATA

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.

Page 23: PENGANTAR MANAJEMEN BASIS DATA

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

Page 24: PENGANTAR MANAJEMEN BASIS DATA

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

Page 25: PENGANTAR MANAJEMEN BASIS DATA

Example: Atomic Transaction

Page 26: PENGANTAR MANAJEMEN BASIS DATA

Example: Atomic Transaction

Page 27: PENGANTAR MANAJEMEN BASIS DATA

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

Page 28: PENGANTAR MANAJEMEN BASIS DATA

Example: Concurrent Transactions

Page 29: PENGANTAR MANAJEMEN BASIS DATA

Example: Lost Update Problem

Page 30: PENGANTAR MANAJEMEN BASIS DATA

Resource Locking •  Resource locking prevents multiple applications

from obtaining copies of the same record when the record is about to be changed

Page 31: PENGANTAR MANAJEMEN BASIS DATA

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

Page 32: PENGANTAR MANAJEMEN BASIS DATA

Example: Explicit Locks

Page 33: PENGANTAR MANAJEMEN BASIS DATA

Deadlock •  Deadlock, or the deadly embrace, occurs

when two transactions are each waiting on a resource that the other transaction holds

Page 34: PENGANTAR MANAJEMEN BASIS DATA

Example: Deadlock

Page 35: PENGANTAR MANAJEMEN BASIS DATA

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

Page 36: PENGANTAR MANAJEMEN BASIS DATA

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

Page 37: PENGANTAR MANAJEMEN BASIS DATA

Example: Marking Transaction Boundaries

Page 38: PENGANTAR MANAJEMEN BASIS DATA

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

Page 39: PENGANTAR MANAJEMEN BASIS DATA

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

Page 40: PENGANTAR MANAJEMEN BASIS DATA

DBMS Security Model

Page 41: PENGANTAR MANAJEMEN BASIS DATA

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

Page 42: PENGANTAR MANAJEMEN BASIS DATA

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

Page 43: PENGANTAR MANAJEMEN BASIS DATA

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

Page 44: PENGANTAR MANAJEMEN BASIS DATA

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

Page 45: PENGANTAR MANAJEMEN BASIS DATA

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

Page 46: PENGANTAR MANAJEMEN BASIS DATA

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

Page 47: PENGANTAR MANAJEMEN BASIS DATA

Example: Rollback •  Before-images: a copy of every

database record (or page) before it was changed

Page 48: PENGANTAR MANAJEMEN BASIS DATA

Example: Rollforward •  After-images: a copy of every database

record (or page) after it was changed

Page 49: PENGANTAR MANAJEMEN BASIS DATA

Example: Transaction Log

Page 50: PENGANTAR MANAJEMEN BASIS DATA

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

Page 51: PENGANTAR MANAJEMEN BASIS DATA

Overview of System Architecture

Database Cache

Log Buffer

Stable Database

Stable Log

Database Page

Database Page

Log Entry

Log Entry

read

write

begin

commit, rollback

write

fetch flush force Volatile Memory Stable

Storage

Database Server

Page 52: PENGANTAR MANAJEMEN BASIS DATA

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!

Page 53: PENGANTAR MANAJEMEN BASIS DATA

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.

Query Optimization and Execution

Relational Operators

Files and Access Methods

Buffer Management

Disk Space Management

DB

These layers must consider concurrency control and recovery

Page 54: PENGANTAR MANAJEMEN BASIS DATA

54

Page 55: PENGANTAR MANAJEMEN BASIS DATA

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

Page 56: PENGANTAR MANAJEMEN BASIS DATA

3. Dari contoh kasus yang sudah ditentukan b u a t R a n c a n g a n D a t a b a s e d a n 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

Page 57: PENGANTAR MANAJEMEN BASIS DATA

Contoh : •  Aplikasi ATM untuk Modul Informasi Saldo •  Rancangan Database

57

Page 58: PENGANTAR MANAJEMEN BASIS DATA

•  Form Input

58

Page 59: PENGANTAR MANAJEMEN BASIS DATA

•  OUTPUT

59

Nomor Rekening : …. Nama : …. Saldo : X.XXX.XXX

Page 60: PENGANTAR MANAJEMEN BASIS DATA

FORMAT PRESENTASI •  NAMA SISTEM INFORMASI •  GAMBARAN UMUM SISTEM INFORMASI •  SUB SISTEM •  RANCANGAN DATABASE •  APLIKASI SEDERHANA à LANGSUNG

KE PROGRAM –  INPUT – OUTPUT

60