Anda di halaman 1dari 32

DATABASE DESIGN

Bag.2
Overview
Miranda : Ariel kamu benar, database management sistem
adalah alat yang cocok untuk job ini
Ariel : Jadi kamu memutuskan mengambil pekerjaan itu ?
Miranda : iya, bayarannya cocok dan perusahaan memberikan
kebebasan waktu menggerjakannya, tapi saya
dibayar ketika pekerjaan selesai .
Ariel : Bagus, kapan kamu mulai ?
Miranda : Itulah masalah berikutnya, saya bingung harus mulai
darimana.
Ariel : Itu adalah masalah, apakah kamu tahu aplikasi
tersbt dapat untuk apa saja ?
Miranda : saya sudah bicara dengan manager dan beberapa
pekerja, tetapi mereka banyak memberikan point,
saya menjadi tidak jelas. Proyek ini besar dan saya
pikir saya mempunyai masalah terhadap seluruh
detailnya. Banyak laporan yang hrs dibuat dan aturan-
aturan. Dan satu orang bagian penjualan banyak
bicara mengenai aturan data, seperti nomor customer
yang terdiri dari 5 digit dan 4 digit dan 2 huruf untuk
account pemerintah.
Ariel : Mungkin kamu harus membuat sebuah sistem dan
membuat diagram dari yang mereka katakan .
Desain Model
Customer(customerID,name,address…)
Salesperson(employeedid,name commission…)
Order (orderid, orderdate, customerid, employeeid…)

Conceptual Implementasi Physical data


User view
of data data model (relational) storage
data model

Diagram yang Daftar dari


menunjukkan entiti, tabel yang Cara
relationship dan digunakan. penyimpanan
rules
Desain sistem
 Indentifikasi kebutuhan user
 Data apa yang perlu dikumpulkan
 Type data

 Jumlah data yang terlibat

3 hal ini akan digunakan untuk membuat class


diagram
Class Diagrams (ERD)
 Diagram yang menggambarkan hubungan
antar entiti yang ada.
 Entiti adalah objek
Pegawai

n m n
Komponen Product
* animal
1 *
Animal
* purchase

1 1 1
1 1
Supplier employee * sale * customer
1 *
1

*
Merchandise
*
* purchase * merchandise *
Tipe data (Domain)
Tipe data Format Size Range of data

Text Fixed Length 1 to 64 K bytes


Variable length 1 to 2 G bytes
Memo/Note

Numeric Byte 1 byte 0 – 255


Boolean 2 bytes True or flase
Integer 2 bytes -32.768 to 32.767
Long 4 bytes -2.147.483.618 to 2.147.483.617
Floating 4 bytes 1.401298E-45 to 3.402823E38
Double 8 bytes 4.97065645847247E-324 to
1.79769313486232E508
Currency 8 bytes -922.377.203.685.477.5808 to
922.377.203.685.477.5807

Date/Time 8 bytes Jan, 1, 100 to dec 31,9999

Object Type apasaja yang dikenal oleh mesin contoh : gambar, suara video
Defenisi dasar
Primary key properties

Row/object Entity : pegawai

Pegawaiid npwp nama telprumah alamat


12512 888-22-5552 Abdul 323-9893 Anggrek 25
15293 222-55-3737 Roland 888-6667 Seruni 10
22343 293-87-4343 John 222-9384 Kemuning 22
29387 837-36-2933 Susan 330-9837 Mangga 7
Key
 Primary key ,kunci utama dalam tabel
 Composite key(kunci kombinasi), kunci yang tersusun
lebih dari satu atribut
 Candidate key, kunci yang dpt dipakai untuk
mengidentifikasikan suatu baris dalam tabel.
 Alternatife key, semua kunci kandidat yang tidak sebagai
primary key
 Foreign key, atribut yang menunjuk ke primary key pada
tabel lain.
Notation
 Orang lebih mudah membaca secara visual

Customer Salesperson
1 1
n n
Order
1
n
Customer(customerID,Name,address,city,phone)
Orderitem
Salesperson(EmployeeID,Name,Commission,DateHired)
1 Orderitem(orderID, itemID, Quantity)
n
Item(itemID,Description, listprice)
item
Initial objects
 Indentifikasi object utama
Initial object2
Initial object Key Sample propeties Comment

Customer CustomerID Name


Address
Phone
Video VideoID Title
Rentalprice
Rating
Description
Rentaltransaction TransactionID CustomerID Event/relationship
Rentdate

Videorented Transactionid + videoid Copy Event/repeating list


Evaluasi form
Alokasi masalah pengulangan data
 Penyimpanan pengulangan data
 Alokasikan tempat
 Berapa banyak ?
• Dapat dibuat pendek
• Membuang tempat
 Contoh : berapa banyak video yang
akan disewa pada suatu saatName Customer rentals
Phone
Address
City
State
Zipcode

VideoId Cop;y Title Rent


1. 6 1 Clockwwork 1.5
28 2 Hopscotch 1.5
3
4
5 [ unused space ]
First normal form (1 NF)

Rentalform(TransID, Rentdate,CustomerID, Phone, Name,


Address, City, state, zipcode, videoID, copy#,title,rent)

Rentalform2(transID, rentdate, customerID, phone, name,


address, city, state, zipcode)

Rentalline(transID, videoID, copy#, title, rent)

Pindahkan bagian yang berulang


Jadikan 2 table
 bawa kunci dari main table ke bagian yang berulang
Rentalline(TransID, VideoID, Copy#,….)
Setiap transaksi dapat mempunyai banyak video ( key video ID)
 1 video dapat disewa dlm banyak transaksi ( key transID)
Setiap transID dan VideoID, hanya 1 copy ( tdk ada key on copy#)
Independent groups

FormA(key1, simplecolumns, (group1, a, b,c), (group2, X, Y))

Maintable(key1,simplecolumns)
group2(key1, group2, X, Y)

Group1(Key1, group1, a, b,c),


Nested repeating groups

Table(key1, …, (key2, …, (key3, …,) ) )

Table1 (key1, … ) TableA (key1, key2, . . . ,( key3, . . .) )

Table2(key1, key2, . . . ) Table3(key1, key2, key3, . . .)


Nested: table (key1, aaa, . . . (key2, bbb, . . . (key3, ccc, . . .)))
First normal form ( 1 NF)
table1 (key1, aaa, . . . )
table2 ( key1, key2, bbb, . . . )
table3 (key1, key2, key3, ccc, . . .)
Permasalahan 1 NF
Second normal form ( 2 NF)

Tergantung pd transID & videoID

Rental line ( transID, videoID, copy#, title, Rent )

Tergantung pd videoID

Setiap nonkey kolom hrs tergantung pd entri key


hanya tergantung pd kandidat key
Beberapa field tergantung pd 1 key
Buat table baru
Membuat 2 NF
Rental line ( transID, videoID, copy#, title, Rent )

VideoRented (TransID, VideoID, Copy#)

Videos ( videoID, title, rent)

Title bergantung pd videoID


setiap video hanya punya 1 judul
Rent bergantung pd videoID
Setiap nonkey bergantung pd key ditable bersangkutan
Data 2 NF
VideoRented (TransID, VideoID, Copy#)

TransID VideoID Copy#


1 1 2
Videos ( videoID, title, rent)
1 6 3
2 2 1 VideoID Title Rent

2 6 1 1 A Space odyssey $ 1.5

2 8 1 2 Apocalypse now $ 2.0

3 4 1 3 Blues brother $ 2.0

4 3 1 4 Boys and his dog $ 2.5


5 Brother from planet $ 2.00

6 Clockwork $ 1.5
Third Normal form ( 3 NF)
Tergantung pd transID

Rentalform2(transID, rentdate, customerID, phone, name, address, city, state, zipcode)

Tergantung pd CustomerID

Setiap non-key hrs tergantung penuh pd key


Jika ada field yang tdk tergantung pd key hrs buat table baru
Third normal form table
Data rules and intergrity
Order
O# Odate C#
 Contoh rules
 Limit data 1173 1-4-97 321
• Harga > 0
1174 1-5-97 938
• Gaji < 100,000
• Datehire > 1/12/1995 1185 1-8-97 337
 Memilih dari himpunan 1190 1-9-97 321
1192 1-9-97 776
 Referential integrity Tdk ada data
 Foreign key dlm suatu table hrs ada dlm master key
 Order (O#, ODate, C#, . . .)
Customer
 C#, hrs ada di table customer
C# Name Phone
321 Jones 9983-
337 Sanchez 7738-
938 Carson 8738
Konversi dari class diagram ke
tabel normalisasi
manager

n 1
1 n n 1
supplier Purchase order Employee
n

n
item
One to many relationship

1 n n 1
supplier Purchase order Employee

Supplier(SID, Name, address, city, state, zip,phone)


Employee(EID, Name, salary, address, . . . )

PurchaseOrder( POID, Date, SID, EID)


Many to Many Relationship
PurchaseOrder(POID, Date, SID, EID)
Purchase order

1
Purchase order
n POItem (POID, ItemID, Quantity, Price)
n
POitem
n n
item

Item (ItemID, Description, Listprice)

1
item
Data Dictionary

 Kamus data, data repository, metadata


 Kumpulan data tentang data yang
disimpan dalam database
Volume data
(contoh)
Customer(C#, Name, address, City, State, Zip)
Row ; 4 + 15 + 25 + 20 + 2 + 10 = 76

Order (O#, C#, Odate)


Row : 4 + 4 + 8 = 16
Orderitem(O#, P#, Quantity, saleprice)
Row : 4 + 4 + 4 + 8 = 20
Order dlm 3 thn = 1000 customer * 10 order/customer * 3 thn = 30.000
Orderitem = 30.000 order * 5 lines/order = 150.000

Customer 76*1000 76.000


Business rules Order 16*30000 480.000
 data disimpan 3 thn
OrderItem 20*150000 3.000.000
 1.000 customer
 rata-rata 10 order per customer Total 3.556.000
 rata-rata 5 item per oder
Web site Reference
http://www.rational.com/uml

www.sybase.com/products/application_tools

www.oracle.com/tools

www.dbpd.com

Anda mungkin juga menyukai