Anda di halaman 1dari 14

Juanysa Wahyu Trisfardha

XI RPL 1

Microsoft Windows [Version 6.3.9600]

(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\acer>cd..

C:\Users>cd..

C:\>cd xampp/mysql/bin

C:\xampp\mysql\bin>mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 32

Server version: 5.0.51 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database perpustakaan;

Query OK, 1 row affected (0.08 sec)

mysql> use perputakaan;

ERROR 1049 (42000): Unknown database 'perputakaan'

mysql> use perpustakaan;

Database changed

mysql> create table tbl_anggota(id_anggota int(20),nama_anggota char(20),alamat varchar(30),no_tlp


int(20));

Query OK, 0 rows affected (0.11 sec)

mysql> Alter table tbl_anggota ADD PRIMARY KEY(id_anggota);

Query OK, 0 rows affected (0.22 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> create table tbl_rak(kode_rak int(20),lokasi varchar(30));

Query OK, 0 rows affected (0.11 sec)

mysql> Alter table tbl_rak ADD PRIMARY KEY(kode_rak);

Query OK, 0 rows affected (0.14 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> create table tbl_reg_buku(no_reg int(20),id_buku int(20),kode_rak int(20));

Query OK, 0 rows affected (0.09 sec)


mysql> Alter table tbl_reg_buku ADD PRIMARY KEY(no_reg);

Query OK, 0 rows affected (0.16 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> create table tbl_penerbit(id_penerbit int(20),nama_penerbit char(20),alamat varchar(30),no_tlp


int(20));

Query OK, 0 rows affected (0.08 sec)

mysql> Alter table tbl_penerbit ADD PRIMARY KEY(id_penerbit);

Query OK, 0 rows affected (0.11 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> create table tbl_pengarang(id_pengarang int(20),nama_pengarang char(20),alamat


varchar(30),no_tlp int(20));

Query OK, 0 rows affected (0.09 sec)

mysql> Alter table tbl_pengarang ADD PRIMARY KEY(id_pengarang);

Query OK, 0 rows affected (0.05 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> create table tbl_buku(id_buku int(20),judul_buku char(30),id_penerbit int(20),id_pengarang


int(20),tahun_buku int(10),jumlah_buku int(100),tanggal_pengadaan date);

Query OK, 0 rows affected (0.11 sec)

mysql> Alter table tbl_buku ADD PRIMARY KEY(id_buku);

Query OK, 0 rows affected (0.11 sec)

Records: 0 Duplicates: 0 Warnings: 0


mysql> create table tbl_peminjaman(kode_transaksi int(20),id_anggota int(20),id_buku
int(20),tanggal_pinjam date,tanggal_kembali date,denda varchar(50));

Query OK, 0 rows affected (0.05 sec)

mysql> Alter table tbl_peminjaman ADD PRIMARY KEY(kode_transaksi);

Query OK, 0 rows affected (0.14 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> desc tbl_anggota;

+--------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------------+-------------+------+-----+---------+-------+

| id_anggota | int(20) | NO | PRI | 0 | |

| nama_anggota | char(20) | YES | | NULL | |

| alamat | varchar(30) | YES | | NULL | |

| no_tlp | int(20) | YES | | NULL | |

+--------------+-------------+------+-----+---------+-------+

4 rows in set (0.00 sec)

mysql> ALTER TABLE tbl_peminjaman ADD FOREIGN KEY(id_anggota) references


tbl_anggota(id_anggota);

Query OK, 0 rows affected (0.14 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> ALTER TABLE tbl_buku ADD FOREIGN KEY(id_penerbit) references tbl_penerbit(id_penerbit);

Query OK, 0 rows affected (0.11 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> ALTER TABLE tbl_buku ADD FOREIGN KEY(id_pengarang) references


tbl_pengarang(id_pengarang);
Query OK, 0 rows affected (0.11 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> ALTER TABLE tbl_reg_buku ADD FOREIGN KEY(id_buku) references tbl_buku(id_buku);

Query OK, 0 rows affected (0.13 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> ALTER TABLE tbl_reg_buku ADD FOREIGN KEY(kode_rak) references tbl_rak(kode_rak);

Query OK, 0 rows affected (0.11 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> ALTER TABLE tbl_peminjaman ADD FOREIGN KEY(id_buku) references tbl_reg_buku(id_buku);

Query OK, 0 rows affected (0.13 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> desc tbl_anggota;

+--------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------------+-------------+------+-----+---------+-------+

| id_anggota | int(20) | NO | PRI | 0 | |

| nama_anggota | char(20) | YES | | NULL | |

| alamat | varchar(30) | YES | | NULL | |

| no_tlp | int(20) | YES | | NULL | |

+--------------+-------------+------+-----+---------+-------+

4 rows in set (0.00 sec)

mysql> INSERT INTO tbl_anggota values("1111","Khusnul","Jl.Ciracas","083895226684);

"> ");

Query OK, 1 row affected, 1 warning (0.00 sec)


mysql> INSERT INTO tbl_anggota values("1112","Uca","Jl.Ceger","0895353301016");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO tbl_anggota values("1113","Juanysa","Jl.Fathul","085893203604");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select*from tbl_anggota;

+------------+--------------+------------+------------+

| id_anggota | nama_anggota | alamat | no_tlp |

+------------+--------------+------------+------------+

| 1111 | Khusnul | Jl.Ciracas | 2147483647 |

| 1112 | Uca | Jl.Ceger | 2147483647 |

| 1113 | Juanysa | Jl.Fathul | 2147483647 |

+------------+--------------+------------+------------+

3 rows in set (0.00 sec)

mysql> desc tbl_anggota;

+--------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------------+-------------+------+-----+---------+-------+

| id_anggota | int(20) | NO | PRI | 0 | |

| nama_anggota | char(20) | YES | | NULL | |

| alamat | varchar(30) | YES | | NULL | |

| no_tlp | int(20) | YES | | NULL | |

+--------------+-------------+------+-----+---------+-------+

4 rows in set (0.00 sec)

mysql> desc tbl_rak;


+----------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+-------+

| kode_rak | int(20) | NO | PRI | 0 | |

| lokasi | varchar(30) | YES | | NULL | |

+----------+-------------+------+-----+---------+-------+

2 rows in set (0.00 sec)

mysql> INSERT INTO tbl_rak values("1120","Jl.Ciracas");

Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO tbl_rak values("1121","Jl.Ceger");

Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO tbl_rak values("1122","Jl.Fathul");

Query OK, 1 row affected (0.00 sec)

mysql> select*from tbl_rak;

+----------+------------+

| kode_rak | lokasi |

+----------+------------+

| 1120 | Jl.Ciracas |

| 1121 | Jl.Ceger |

| 1122 | Jl.Fathul |

+----------+------------+

3 rows in set (0.00 sec)

mysql> desc tbl_reg_buku;

+----------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |

+----------+---------+------+-----+---------+-------+

| no_reg | int(20) | NO | PRI | 0 | |

| id_buku | int(20) | YES | MUL | NULL | |

| kode_rak | int(20) | YES | MUL | NULL | |

+----------+---------+------+-----+---------+-------+

3 rows in set (0.00 sec)

mysql> INSERT INTO tbl_reg_buku values("1130","111","1120");

Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO tbl_reg_buku values("1131","112","1121");

Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO tbl_reg_buku values("1132","113","1122");

Query OK, 1 row affected (0.00 sec)

mysql> select*from tbl_reg_buku;

+--------+---------+----------+

| no_reg | id_buku | kode_rak |

+--------+---------+----------+

| 1130 | 111 | 1120 |

| 1131 | 112 | 1121 |

| 1132 | 113 | 1122 |

+--------+---------+----------+

3 rows in set (0.00 sec)

mysql> desc tbl_penerbit;

+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |

+---------------+-------------+------+-----+---------+-------+

| id_penerbit | int(20) | NO | PRI | 0 | |

| nama_penerbit | char(20) | YES | | NULL | |

| alamat | varchar(30) | YES | | NULL | |

| no_tlp | int(20) | YES | | NULL | |

+---------------+-------------+------+-----+---------+-------+

4 rows in set (0.00 sec)

mysql> INSERT INTO tbl_anggota values("1140","Tere Liye","Jl.Arsa","083895226684");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO tbl_penerbit values("1140","Tere Liye","Jl.Arsa","083895226684");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO tbl_penerbit values("1141","Ilana Tan","Jl.Berasel","0895326646177");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO tbl_penerbit values("1142","Fiersa Besari","Jl.Erdiana","085893203604");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select*from tbl_penerbit;

+-------------+---------------+------------+------------+

| id_penerbit | nama_penerbit | alamat | no_tlp |

+-------------+---------------+------------+------------+

| 1140 | Tere Liye | Jl.Arsa | 2147483647 |

| 1141 | Ilana Tan | Jl.Berasel | 2147483647 |

| 1142 | Fiersa Besari | Jl.Erdiana | 2147483647 |

+-------------+---------------+------------+------------+
3 rows in set (0.00 sec)

mysql> desc tbl_pengarang;

+----------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+----------------+-------------+------+-----+---------+-------+

| id_pengarang | int(20) | NO | PRI | 0 | |

| nama_pengarang | char(20) | YES | | NULL | |

| alamat | varchar(30) | YES | | NULL | |

| no_tlp | int(20) | YES | | NULL | |

+----------------+-------------+------+-----+---------+-------+

4 rows in set (0.00 sec)

mysql> INSERT INTO tbl_pengarang values("1150","Nathan","Jl.Mekarsari","085893203604");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO tbl_pengarang values("1151","DIlan","Jl.Nayang","0895326646177");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO tbl_pengarang values("1152","Milea","Jl.Renov","082291969790");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select*from tbl_pengarang;

+--------------+----------------+--------------+------------+

| id_pengarang | nama_pengarang | alamat | no_tlp |

+--------------+----------------+--------------+------------+

| 1150 | Nathan | Jl.Mekarsari | 2147483647 |

| 1151 | DIlan | Jl.Nayang | 2147483647 |

| 1152 | Milea | Jl.Renov | 2147483647 |


+--------------+----------------+--------------+------------+

3 rows in set (0.00 sec)

mysql> desc tbl_buku;

+-------------------+----------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------------------+----------+------+-----+---------+-------+

| id_buku | int(20) | NO | PRI | 0 | |

| judul_buku | char(30) | YES | | NULL | |

| id_penerbit | int(20) | YES | MUL | NULL | |

| id_pengarang | int(20) | YES | MUL | NULL | |

| tahun_buku | int(10) | YES | | NULL | |

| jumlah_buku | int(100) | YES | | NULL | |

| tanggal_pengadaan | date | YES | | NULL | |

+-------------------+----------+------+-----+---------+-------+

7 rows in set (0.00 sec)

mysql> INSERT INTO tbl_buku values("111","Komet","1140","1150","2002","40","14 Juni 2013");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO tbl_buku values("112","Bintang","1141","1151","2003","20","25 Desember 2015");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO tbl_buku values("113","Bumi","1142","1152","2005","20","29 Oktober 2018");

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select*from tbl_buku;

+---------+------------+-------------+--------------+------------+-------------+-------------------+
| id_buku | judul_buku | id_penerbit | id_pengarang | tahun_buku | jumlah_buku |
tanggal_pengadaan |

+---------+------------+-------------+--------------+------------+-------------+-------------------+

| 111 | Komet | 1140 | 1150 | 2002 | 40 | 0000-00-00 |

| 112 | Bintang | 1141 | 1151 | 2003 | 20 | 0000-00-00 |

| 113 | Bumi | 1142 | 1152 | 2005 | 20 | 0000-00-00 |

+---------+------------+-------------+--------------+------------+-------------+-------------------+

3 rows in set (0.00 sec)

mysql> UPDATE tbl_buku set tanggal_pengadaan='2013-06-14' where jumlah_buku='40';

Query OK, 1 row affected (0.17 sec)

Rows matched: 1 Changed: 1 Warnings: 0

mysql> select*from tbl_buku;

+---------+------------+-------------+--------------+------------+-------------+-------------------+

| id_buku | judul_buku | id_penerbit | id_pengarang | tahun_buku | jumlah_buku |


tanggal_pengadaan |

+---------+------------+-------------+--------------+------------+-------------+-------------------+

| 111 | Komet | 1140 | 1150 | 2002 | 40 | 2013-06-14 |

| 112 | Bintang | 1141 | 1151 | 2003 | 20 | 0000-00-00 |

| 113 | Bumi | 1142 | 1152 | 2005 | 20 | 0000-00-00 |

+---------+------------+-------------+--------------+------------+-------------+-------------------+

3 rows in set (0.00 sec)

mysql> UPDATE tbl_buku set tanggal_pengadaan='2015-12-25' where jumlah_buku='20';

Query OK, 2 rows affected (0.00 sec)

Rows matched: 2 Changed: 2 Warnings: 0

mysql> UPDATE tbl_buku set tanggal_pengadaan='2085-10-29' where jumlah_buku='20';


Query OK, 2 rows affected (0.00 sec)

Rows matched: 2 Changed: 2 Warnings: 0

mysql> select*from tbl_buku;

+---------+------------+-------------+--------------+------------+-------------+-------------------+

| id_buku | judul_buku | id_penerbit | id_pengarang | tahun_buku | jumlah_buku |


tanggal_pengadaan |

+---------+------------+-------------+--------------+------------+-------------+-------------------+

| 111 | Komet | 1140 | 1150 | 2002 | 40 | 2013-06-14 |

| 112 | Bintang | 1141 | 1151 | 2003 | 20 | 2085-10-29 |

| 113 | Bumi | 1142 | 1152 | 2005 | 20 | 2085-10-29 |

+---------+------------+-------------+--------------+------------+-------------+-------------------+

3 rows in set (0.00 sec)

mysql> desc tbl_peminjaman;

+-----------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-----------------+-------------+------+-----+---------+-------+

| kode_transaksi | int(20) | NO | PRI | 0 | |

| id_anggota | int(20) | YES | MUL | NULL | |

| id_buku | int(20) | YES | MUL | NULL | |

| tanggal_pinjam | date | YES | | NULL | |

| tanggal_kembali | date | YES | | NULL | |

| denda | varchar(50) | YES | | NULL | |

+-----------------+-------------+------+-----+---------+-------+

6 rows in set (0.01 sec)

mysql> INSERT INTO tbl_peminjaman values("6655","1111","111","2012-02-23","2012-03-


01","Rp.2000");
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO tbl_peminjaman values("6656","1112","112","2014-10-10","2014-11-


05","Rp.6000");

Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO tbl_peminjaman values("6657","1113","113","2016-07-05","2016-09-


20","Rp.4000");

Query OK, 1 row affected (0.00 sec)

mysql> select*from tbl_peminjaman;

+----------------+------------+---------+----------------+-----------------+---------+

| kode_transaksi | id_anggota | id_buku | tanggal_pinjam | tanggal_kembali | denda |

+----------------+------------+---------+----------------+-----------------+---------+

| 6655 | 1111 | 111 | 2012-02-23 | 2012-03-01 | Rp.2000 |

| 6656 | 1112 | 112 | 2014-10-10 | 2014-11-05 | Rp.6000 |

| 6657 | 1113 | 113 | 2016-07-05 | 2016-09-20 | Rp.4000 |

+----------------+------------+---------+----------------+-----------------+---------+

3 rows in set (0.00 sec)

mysql> select
tbl_anggota.id_anggota,tbl_anggota.nama_anggota,tbl_peminjaman.id_buku,tbl_buku.judul_buku from
tbl_buku inner join tbl_anggota inner join tbl_peminjaman on tbl_anggota.id_anggota = tbl_

peminjaman.id_anggota and tbl_peminjaman.id_buku = tbl_buku.id_buku;

+------------+--------------+---------+------------+

| id_anggota | nama_anggota | id_buku | judul_buku |

+------------+--------------+---------+------------+

| 1111 | Khusnul | 111 | Komet |

| 1112 | Uca | 112 | Bintang |

| 1113 | Juanysa | 113 | Bumi |

+------------+--------------+---------+------------+

3 rows in set (0.06 sec)