Anda di halaman 1dari 3

MJ514 BASIS DATA

Pokok Bahasan Data Definition Language (DDL)


Data Manipulation Language (DML)
TIK 1. Memahami konsep SQL
2. Membuat query dengan baik dan benar
3. Memahami cara kerja dan fitur-fitur yang dimiliki DBMS
MySQL serta mampu mengimplementasikan aplikasi
database dalam DBMS MySQL
Setoran File teks hasil log MySQL

Petunjuk:
Gunakan option --tee=<nama-file>.txt pada saat menjalankan mysql agar semua
perintah yang dijalankan tersimpan dalam sebuah file teks. File text tersebut yang harus
Anda kumpulkan sebagai hasil praktikum.

1. Buatlah sebuah database bernama banking.


2. Di dalam database tersebut, buatlah tabel-tabel berikut :
a. Nama tabel : account
Field Type Constraint
number char(3) not null, primary key
cust_id integer not null,
foreign key references customer(id)
balance numeric(9,2) not null
type varchar(10) not null

b. Nama tabel : deposit


Field Type Constraint
account_number char(3) not null,
foreign key references
account(number)
transaction_id char(5) not null, primary key
date date not null
dep_amount numeric(9,2) not null

c. Nama tabel : checks


Field Type Constraint
account_number char(3) not null, primary key,
foreign key references
account(number)
check_number char(7) not null, primary key
date date not null
amount numeric(9,2) not null

1
d. Nama tabel : atmwithdrawal
Field Type Constraint
transaction_id integer not null, primary key
account_number char(3) not null
foreign key references
account(number)
amount numeric(9,2) not null
withdraw_date date not null

e. Nama tabel : customer


Field Type Constraint
id integer not null, primary key
name varchar(20) not null
phone varchar(15) not null
address varchar(20) not null

3. Buatlah kalimat SQL untuk:


a. Menambahkan sebuah field baru pada tabel atmwithdrawal bernama cust_id
dengan type char(3) dan merupakan foreign key ke tabel customer(id)
b. Mengganti nama field dep_amount menjadi amount dengan type numeric(9,2)

4. Isilah tabel-tabel tersebut dengan data berikut:


a. Nama tabel : customer
id name phone address
1 J. Smith 335-6789 Stamford
3 M. Jones 552-9876 Harrison

b. Nama tabel : account


number cust_id balance type
101 1 1000 checking
104 3 1000 checking

c. Nama tabel : checks


account_number check_number date amount
104 104-237 2008-04-09 1000
101 101-889 2008-04-13 500

d. Nama tabel : deposit


account_number transaction_id date amount

2
101 D-001 2008-04-01 500
101 D-004 2008-04-05 2500

e. Nama tabel : atmwithdrawal


transaction_id cust_id account_number amount withdraw_date
3 1 101 40 2008-04-12
4 3 104 200 2008-04-13

5. Buatlah kalimat SQL untuk:


a. Mengubah field address dari customer dengan name M. Jones menjadi Pittsfield
b. Menambah balance dari semua account bertype checking dengan 15%
c. Menghapus data deposit tanggal 2008-04-09

6. Upload file P02YYXXX.txt ke learning.polibatam.ac.id pada tempat yang


disediakan

Anda mungkin juga menyukai