RANCANGAN STRUKTUR TABEL
DATABASE YG DIGUNAKAN (DLM BENTUK 3NF)
1. Tabel: user
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
user_name
|
VarChar
|
20
|
No
|
-
|
Primary Key
|
2
|
password
|
VarChar
|
20
|
No
|
-
|
-
|
3
|
level_user
|
Char
|
1
|
No
|
5
|
1 = admin; 2 =
kepala sekolah; 3 = kepala
perpustakaan
4 = anggota; 5 = pengunjung
|
2. Tabel: tanggal_libur
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
tanggal_libur
|
Date
|
|
no
|
-
|
Primary Key
|
2
|
Keterangan_libur
|
Varchar
|
50
|
no
|
-
|
-
|
3. Tabel: tarif_denda
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
jumlah_hari_maksimal
|
Num
|
3
|
No
|
-
|
Primary Key
|
2
|
jumlah_denda
|
Num
|
7
|
No
|
-
|
-
|
4. Tabel: tarif _hilang
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
harga_maksimal
|
Num
|
7
|
No
|
-
|
Primary Key
|
2
|
jumlah_denda
|
Num
|
7
|
No
|
-
|
-
|
5. Tabel: tarif _rusak
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
harga_maksimal
|
Num
|
7
|
No
|
-
|
Primary Key
|
2
|
jumlah_denda
|
Num
|
7
|
No
|
-
|
-
|
6. Tabel: anggota
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_anggota
|
Char
|
6
|
no
|
-
|
Primary Key
|
2
|
nama_anggota
|
VarChar
|
100
|
no
|
-
|
-
|
3
|
Alamat
|
VarChar
|
100
|
no
|
-
|
-
|
4
|
kode_kecamatan
|
Char
|
6
|
no
|
-
|
Foreign Key
|
5
|
Telepon
|
VarChar
|
12
|
yes
|
-
|
-
|
6
|
Email
|
VarChar
|
20
|
yes
|
-
|
-
|
7
|
tgl_mulai_anggota
|
Date
|
|
no
|
-
|
-
|
8
|
jenis_anggota
|
Char
|
1
|
no
|
2
|
1 = guru/ karyawan; 2 = siswa
|
9
|
status_anggota
|
Char
|
1
|
no
|
2
|
1 = aktif; 2 = tidak aktif
|
7. Tabel: jenis
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_jenis_buku
|
Char
|
4
|
No
|
-
|
Primary Key
|
2
|
nama_jenis_buku
|
VarChar
|
20
|
No
|
-
|
-
|
8. Tabel: bidang
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_bidang
|
Char
|
4
|
No
|
-
|
Primary Key
|
2
|
nama_bidang
|
VarChar
|
20
|
No
|
-
|
-
|
9. Tabel: penerbit
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_penerbit
|
Char
|
4
|
No
|
-
|
Primary Key
|
2
|
nama_penerbit
|
VarChar
|
30
|
No
|
-
|
-
|
3
|
Alamat
|
VarChar
|
100
|
no
|
-
|
-
|
4
|
kode_kecamatan
|
Char
|
6
|
no
|
-
|
Foreign Key
|
5
|
Telepon
|
VarChar
|
12
|
yes
|
-
|
-
|
6
|
Email
|
VarChar
|
20
|
yes
|
-
|
-
|
10. Tabel: penulis
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_penulis
|
Char
|
4
|
No
|
-
|
Primary Key
|
2
|
nama_penulis
|
VarChar
|
100
|
No
|
-
|
-
|
3
|
Alamat
|
VarChar
|
100
|
no
|
-
|
-
|
4
|
kode_kecamatan
|
Char
|
6
|
no
|
-
|
Foreign Key
|
5
|
Telepon
|
VarChar
|
12
|
yes
|
-
|
-
|
6
|
Email
|
VarChar
|
20
|
yes
|
-
|
-
|
11. Tabel: propinsi
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_propinsi
|
Char
|
2
|
No
|
-
|
Primary Key
|
2
|
nama_propinsi
|
VarChar
|
30
|
No
|
-
|
-
|
12. Tabel: kabupaten
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_kabupaten
|
Char
|
4
|
No
|
-
|
Primary Key
|
2
|
nama_kabupaten
|
VarChar
|
30
|
No
|
-
|
-
|
3
|
kode_propinsi
|
Char
|
2
|
No
|
-
|
Foreign Key
|
13. Tabel: kecamatan
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_kecamatan
|
Char
|
6
|
No
|
-
|
Primary Key
|
2
|
nama_kecamatan
|
VarChar
|
30
|
No
|
-
|
-
|
3
|
kode_kabupaten
|
Char
|
4
|
No
|
-
|
Foreign Key
|
14. Tabel: pinjam
Catatan: kode_pinjam boleh tidak digunakan
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_pinjam
|
|
|
|
|
Primary Key
|
2
|
kode_anggota
|
Char
|
6
|
No
|
-
|
Primary Key / Foreign Key
|
3
|
kode_buku
|
Char
|
10
|
No
|
-
|
Primary Key / Foreign Key
|
4
|
tanggal_pinjam
|
Date
|
|
No
|
|
Primary Key / Foreign Key
|
5
|
tanggal_harus_kembali
|
Date
|
|
N0
|
-
|
-
|
15. Tabel: kembali
Catatan:
·
kode_kembaliboleh tidak
digunakan
·
jika tabel pinjam tidak
menggunakan kode_pinjam, maka harus ada kode_anggota+kode_buku+tanggal_pinjam
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_pinjam
|
|
|
|
|
Primary Key / Foreign Key
|
2
|
kode_kembali
|
|
|
|
|
Primary Key
|
3
|
kode_anggota
|
Char
|
6
|
No
|
-
|
Primary Key / Foreign Key
|
4
|
kode_buku
|
Char
|
10
|
No
|
-
|
Primary Key / Foreign Key
|
5
|
tanggal_pinjam
|
Date
|
|
No
|
|
Primary Key / Foreign Key
|
6
|
tanggal_kembali
|
Date
|
|
No
|
-
|
-
|
16. Tabel: bayar_denda
Catatan: jika tabel kembali tidak menggunakan
kode_kembali, maka harus ada
kode_anggota+kode_buku+tanggal_pinjam+tanggal_kembali
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_kembali
|
|
|
|
|
Primary Key / Foreign Key
|
2
|
kode_anggota
|
Char
|
6
|
No
|
-
|
Primary Key/ Foreign Key
|
3
|
kode_buku
|
Char
|
10
|
No
|
-
|
Primary Key/ Foreign Key
|
4
|
tanggal_pinjam
|
Date
|
|
No
|
|
Primary Key/ Foreign Key
|
5
|
tanggal_bayar
|
Date
|
|
No
|
-
|
-
|
6
|
jumlah_denda
|
Num
|
9
|
No
|
0
|
Dihitung otomatis
|
17. Tabel: bayar_hilang
Catatan: jika tabel pinjam tidak menggunakan kode_pinjam,
maka harus ada kode_anggota+kode_buku+tanggal_pinjam
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_pinjam
|
|
|
|
|
Primary Key
/ Foreign Key
|
2
|
kode_anggota
|
Char
|
6
|
No
|
-
|
Primary Key
/ Foreign Key
|
3
|
kode_buku
|
Char
|
10
|
No
|
-
|
Primary Key
/ Foreign Key
|
4
|
tanggal_pinjam
|
Date
|
|
No
|
|
Primary Key
/ Foreign Key
|
5
|
tanggal_bayar
|
Date
|
|
No
|
-
|
-
|
6
|
jumlah_denda
|
Num
|
9
|
No
|
0
|
Dihitung otomatis
|
18. Tabel: bayar_rusak
Catatan: jika tabel pinjam tidak menggunakan
kode_pinjam, maka harus ada kode_anggota+kode_buku+tanggal_pinjam
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_pinjam
|
|
|
|
|
Primary Key / Foreign Key
|
2
|
kode_anggota
|
Char
|
6
|
No
|
-
|
Primary Key / Foreign Key
|
3
|
kode_buku
|
Char
|
10
|
No
|
-
|
Primary Key / Foreign Key
|
4
|
tanggal_pinjam
|
Date
|
|
No
|
|
Primary Key / Foreign Key
|
5
|
tanggal_bayar
|
Date
|
|
No
|
-
|
-
|
6
|
jumlah_denda
|
Num
|
9
|
No
|
0
|
Dihitung otomatis
|
19. Tabel: buku
|
||||||
No
|
Nama Field
|
Tipe
|
Ukuran
|
Null
|
Default
|
Keterangan
|
1
|
kode_buku
|
Char
|
10
|
No
|
-
|
Primary Key
|
2
|
Judul_buku
|
VarChar
|
100
|
No
|
-
|
-
|
3
|
kode_jenis
|
Char
|
4
|
No
|
-
|
Foreign Key
|
4
|
kode_bidang
|
Char
|
4
|
No
|
-
|
Foreign Key
|
5
|
kode_penulis_utama
|
Char
|
4
|
No
|
-
|
Foreign Key
|
6
|
kode_penerbit
|
Char
|
4
|
No
|
-
|
Foreign Key
|
7
|
jumlah
|
Num
|
1
|
No
|
-
|
-
|
8
|
bahasa
|
Char
|
1
|
No
|
1
|
1 = Indonesia; 2 = Asing
|
9
|
isbn
|
Char
|
12
|
No
|
-
|
-
|
10
|
tahun
|
Char
|
4
|
No
|
-
|
-
|
11
|
jumlah_halaman
|
Num
|
1
|
No
|
-
|
-
|
12
|
edisi
|
Char
|
1
|
No
|
1
|
-
|
13
|
cetakan_ke
|
Char
|
1
|
No
|
1
|
-
|
14
|
status
|
Char
|
1
|
No
|
1
|
1 = Baik; 2 = Rusak
|
·
DIAGRAM KERELASIAN ANTAR
TABEL DATABASE
·
·
PERINTAH SQL
1. Membuat Database
create database perpustakaan;
2. Membuat Tabel Master dan Transaksi
Use database perpustakaan;
mysql> create table user
(user_name varchar(5) primary key,password varchar(20) ,level_user char(1));
Query OK, 0 rows
affected (0.93 sec)
mysql> create table tanggal_libur (tanggal_libur date primary
key,keterangan_libur varchar(50));
Query OK, 0 rows affected (0.17 sec)
mysql> create table tarif_denda (jumlah_hari_maksimal int(3) primary
key,jumlah_denda int(9));
Query OK, 0 rows affected (0.16 sec)
mysql> create table tarif_hilang (harga_maksimal int (9) primary
key,jumlah_denda int(9));
Query OK, 0 rows affected (0.15 sec)
mysql> create table tarif_rusak (harga_maksimal int (9) primary
key,jumlah_denda int(9));
Query OK, 0 rows affected (0.20 sec)
mysql> create table jenis (kode_jenis_buku char(4) primary
key,nama_jenis_buku varchar(20));
Query OK, 0 rows affected (0.14 sec)
mysql> create table bidang (kode_bidang char(4) primary key,nama_bidang
varchar(20));
Query OK, 0 rows affected (0.15 sec)
mysql> create table propinsi (kode_propinsi char(2) primary
key,nama_propinsi varchar(30));
Query OK, 0 rows affected (0.15 sec)
mysql> create table kabupaten (kode_kabupaten char(4) primary
key,nama_kabupaten varchar(30),kode_propinsi char(2),foreign key(kode_propinsi)
references propinsi(kode_propinsi) on update cascade on delete cascade);
Query OK, 0 rows affected (0.31 sec)
mysql> create table kecamatan (kode_kecamatan char(6) primary key,nama_kecamatan
varchar(30),kode_kabupaten char(4),foreign key(kode_kabupaten) references
kabupaten(kode_kabupaten) on update cascade on delete cascade);
Query OK, 0 rows affected (0.14 sec)
mysql> create table penulis (kode_penulis char(4) primary
key,nama_penulis_utama varchar(100),alamat varchar(100) ,kode_kecamatan
char(6),telepon varchar(12),email varchar(20),foreign key(kode_kecamatan)
references kecamatan(kode_kecamatan) on update cascade on delete cascade);
Query OK, 0 rows affected (0.16 sec)
mysql> create table penerbit (kode_penerbit char(4) primary
key,nama_penerbit varchar(30),alamat varchar(100),kode_kecamatan
char(6),telepon varchar(12),email varchar(20),foreign key(kode_kecamatan)
references kecamatan(kode_kecamatan) on update cascade on delete cascade);
Query OK, 0 rows affected (0.13 sec)
mysql> create table anggota (kode_anggota char(6) primary
key,nama_anggota varchar(100),alamat varchar(100),kode_kecamatan char(6),telepon
varchar(12),email varchar(20),tgl_mulai_anggota date ,jenis_anggota
char(1),status_anggota char(1),foreign key (kode_kecamatan) references
kecamatan(kode_kecamatan) on update cascade on delete cascade);
Query OK, 0 rows affected (0.12 sec)
mysql> create table buku (kode_buku char(10) primary key,judul_buku
varchar(100) ,kode_jenis_buku char(4) ,kode_bidang char(4),kode_penulis
char(4),kode_penerbit char(4),jumlah int(2),bahasa char(1) ,isbn char(12)
,tahun char(4),jumlah_halaman int(4),edisi char(1) ,cetakan_ke char(1),status
char(1),foreign key(kode_jenis_buku) references jenis(kode_jenis_buku) on
update cascade on delete cascade,foreign key(kode_bidang) references
bidang(kode_bidang) on update cascade on delete cascade,foreign
key(kode_penulis) references penulis(kode_penulis) on update cascade on delete
cascade,foreign key(kode_penerbit) references penerbit(kode_penerbit) on update
cascade on delete cascade);
Query OK, 0 rows affected (0.42 sec)
mysql> create table pinjam (kode_pinjam varchar(2), kode_anggota
char(6),kode_buku char(10),tanggal_pinjam date primary
key,tanggal_harus_kembali date,foreign key(kode_anggota) references
anggota(kode_anggota) on update cascade on delete cascade,foreign
key(kode_buku) references buku(kode_buku) on update cascade on delete cascade);
Query OK, 0 rows affected (0.20 sec)
mysql> create table kembali (kode_pinjam varchar(2), kode_kembali
varchar(2), kode_anggota char(6),kode_buku char(10),tanggal_pinjam date,tanggal_kembali
date,foreign key(kode_anggota) references anggota(kode_anggota) on update
cascade on delete cascade, foreign key(kode_buku) references buku(kode_buku) on
update cascade on delete cascade, foreign key(tanggal_pinjam) references
pinjam(tanggal_pinjam) on update cascade on delete cascade);
Query OK, 0 rows affected (0.21 sec)
mysql> create table bayar_denda (kode_kembali varchar(2),kode_anggota
char(6),kode_buku char(10),tanggal_pinjam date,tanggal_bayar date,jumlah_denda
int(9),foreign key(kode_anggota) references anggota(kode_anggota) on update
cascade on delete cascade, foreign key(kode_buku) references buku(kode_buku) on
update cascade on delete cascade, foreign key(tanggal_pinjam) references
pinjam(tanggal_pinjam) on update cascade on delete cascade);
Query OK, 0 rows affected (0.44 sec)
mysql> create table bayar_hilang (kode_pinjam varchar(2),kode_anggota
char(6),kode_buku char(10),tanggal_pinjam date,tanggal_bayar date,jumlah_denda
int(9), foreign key(kode_anggota) references anggota(kode_anggota) on update
cascade on delete cascade, foreign key(kode_buku) references buku(kode_buku) on
update cascade on delete cascade, foreign key(tanggal_pinjam) references
pinjam(tanggal_pinjam) on update cascade on delete cascade);
Query OK, 0 rows affected (0.29 sec)
mysql> create table bayar_rusak (kode_pinjam varchar(2),kode_anggota
char(6),kode_buku char(10),tanggal_pinjam date,tanggal_bayar date,jumlah_denda
int(9),foreign key(kode_anggota) references anggota(kode_anggota) on update
cascade on delete cascade, foreign key(kode_buku) references buku(kode_buku) on
update cascade on delete cascade, foreign key(tanggal_pinjam) references
pinjam(tanggal_pinjam) on update cascade on delete cascade);
Query OK, 0 rows affected (0.23 sec)
mysql> load data local infile 'E:\user.txt' into table user;
Query OK, 5 rows affected (0.11 sec)
Records: 5 Deleted: 0 Skipped: 0
Warnings: 0
Isi dalam setiap tabel
mysql> select* from user;
+-----------+------------+------------+
| user_name | password | level_user
|
+-----------+------------+------------+
| 111 | 12345 | 1 |
| 112 | 123456 | 2 |
| 113 | 1234567 | 3
|
| 114 | 12345678 | 4
|
| 115 | 1234567890 | 5 |
+-----------+------------+------------+
rows in set (0.00 sec)
mysql>
load data local infile 'E:\libur.txt' into table tanggal_libur;
Query
OK, 5 rows affected (0.16 sec)
Records:
5 Deleted: 0 Skipped: 0
Warnings: 0
mysql>
select* from tanggal_libur;
+---------------+------------------+
|
tanggal_libur | keterangan_libur |
+---------------+------------------+
|2013-01-01 | cuti bersama |
|2013-01-05 | cuti bersama |
|2013-01-08 | cuti
bersama |
|2013-01-10 | cuti
bersama |
|2013-01-15
| cuti
bersama |
+---------------+------------------+
5
rows in set (0.01 sec)
mysql> load data local infile 'E:\denda.txt' into
table tarif_denda;
Query OK, 4 rows affected (0.17 sec)
Records: 5
Deleted: 0 Skipped: 1 Warnings: 0
mysql> select* from tarif_denda;
+----------------------+--------------+
| jumlah_hari_maksimal | jumlah_denda |
+----------------------+--------------+
|
5 | 1500 |
|
6 | 2500 |
|
7 | 1000 |
|
8 | 2000 |
|
9 | 3000 |
+----------------------+--------------+
5 rows in set (0.00 sec)
mysql> load data local infile 'E:\hilang.txt' into
table tarif_hilang;
Query OK, 5 rows affected (0.08 sec)
Records: 5
Deleted: 0 Skipped: 0 Warnings: 0
mysql> select* from tarif_hilang;
+----------------+--------------+
| harga_maksimal | jumlah_denda |
+----------------+--------------+
| 20000
| 40000 |
| 25000
| 50000 |
| 25500
| 51000 |
| 30000
| 60000 |
| 35000
| 70000 |
+----------------+--------------+
5 rows in set (0.01 sec)
mysql> load data local infile 'E:\hilang.txt' into
table tarif_rusak;
Query OK, 5 rows affected (0.18 sec)
Records: 5 Deleted:
0 Skipped: 0 Warnings: 0
mysql> select* from tarif_rusak;
+----------------+--------------+
| harga_maksimal | jumlah_denda |
+----------------+--------------+
| 20000
| 40000 |
| 25000
| 50000 |
| 25500 | 51000 |
| 30000
| 60000 |
| 35000
| 70000 |
+----------------+--------------+
5 rows in set (0.00 sec)
mysql> load data local infile 'E:\jenis.txt' into
table jenis;
Query OK, 5 rows affected (0.09 sec)
Records: 5 Deleted: 0
Skipped: 0 Warnings: 0
mysql> select* from jenis;
+-----------------+-----------------+
| kode_jenis_buku | nama_jenis_buku |
+-----------------+-----------------+
| 1111 |
novel |
| 1112 |
cerpen |
| 1113 | komik |
| 1114 | skripsi |
| 1115 |
sejarah |
+-----------------+-----------------+
5 rows in set (0.00 sec)
mysql> load data local infile 'E:\propinsi.txt' into
table propinsi;
Query OK, 5 rows affected (0.05 sec)
Records: 5
Deleted: 0 Skipped: 0 Warnings: 0
mysql> select* from propinsi;
+---------------+---------------+
| kode_propinsi | nama_propinsi |
+---------------+---------------+
|31 | jawa tengah
|
|32 | jawa tengah
|
|33 | jawa tengah
|
|34 | jawa
tengah |
|35 | jawa
tengah |
+---------------+---------------+
5 rows in set (0.00 sec)
mysql> load data local infile 'E:\kabupaten.txt' into
table kabupaten;
Query OK, 5 rows affected (0.10 sec)
Records: 5
Deleted: 0 Skipped: 0 Warnings: 0
mysql> select* from kabupaten;
+----------------+----------------+---------------+
| kode_kabupaten | nama_kabupaten | kode_propinsi |
+----------------+----------------+---------------+
| 41 |
jogja | 31 |
| 42 |
bantul | 32 |
| 43 |
sleman | 33 |
| 44 |
solo | 34 |
| 45 |
klaten | 35 |
+----------------+----------------+---------------+
5 rows in set (0.00 sec)
mysql> insert into kecamatan values(‘10’,’jogja’,’41’),(‘20’,’bantul’,’42’),(‘30’,’sleman’,’43’),(‘40’,’solo’,‘44’),(‘50’,’klaten’,’45’);
Query OK, 5 rows affected (0.08 sec)
Records: 5
Duplicates: 0 Warnings: 0
mysql> select* from kecamatan;
+----------------+----------------+----------------+
| kode_kecamatan | nama_kecamatan | kode_kabupaten |
+----------------+----------------+----------------+
| 10 |
jogja | 41 |
| 20 |
bantul | 42 |
| 30 |
sleman | 43 |
| 40 |
solo | 44 |
| 50 |
klaten | 45 |
+----------------+----------------+----------------+
5 rows in set (0.00 sec)
mysql> load data local infile 'E:\penulis.txt' into
table penulis;
Query OK, 5 rows affected (0.10 sec)
Records: 5
Deleted: 0 Skipped: 0 Warnings: 0
mysql> select* from penulis;
+--------------+--------------------+---------+----------------+---------+-------------------+
| kode_penulis | nama_penulis_utama | alamat | kode_kecamatan | telepon | email |
+--------------+--------------------+---------+----------------+---------+-------------------+
|21 |
enny | jogja | 10 | 2356 | enny@gmail.com
|22 |
hendra | bantul | 20 | 3468 | hendra@yahoo.com
|23 |
ardi | sleman | 30 | 2378 | ardi@gmail.co.id
|24 |
neni | solo | 40 | 1327 | neni@yahoo.co.id
|25 |
nanda | klaten | 50
| 5890 | nanda@yahoo.com
+--------------+--------------------+---------+----------------+---------+-------------------+
5 rows in set (0.00 sec)
mysql> load data local infile 'E:\penerbit.txt' into
table penerbit;
Query OK, 5 rows affected (0.08 sec)
Records: 5
Deleted: 0 Skipped: 0 Warnings: 0
mysql> select* from penerbit;
+---------------+---------------+---------+----------------+---------+---------------------+
| kode_penerbit | nama_penerbit | alamat | kode_kecamatan | telepon | email |
+---------------+---------------+---------+----------------+---------+---------------------+
|5 | faisal
| klaten | 50 | 5678 | faisal@yahoo.com
|6 |
farida | solo | 40 | 4567 | farida@yahoo.co.id
|7 |
ayudha | sleman | 30 | 3456 | ayudha@gmail.co.id
|8 | alfian
| bantul | 20 | 2345 | alfian@yahoo.com
|9 |
budi | jogja | 10
| 1234 | budi@gmail.com
+---------------+---------------+---------+----------------+---------+---------------------+
5 rows in set (0.00 sec)
mysql> load data local infile 'E:\anggota.txt' into
table anggota;
Query OK, 5 rows affected, 5 warnings (0.09 sec)
Records: 5
Deleted: 0 Skipped: 0 Warnings: 5
mysql> select* from anggota;
+--------------+--------------+--------+----------------+---------+-------------------+-------------------+---------------+----------------+
| kode_anggota | nama_anggota | alamat | kode_kecamatan |
telepon | email |
tgl_mulai_anggota | jenis_anggota | status_anggota |
+--------------+--------------+--------+----------------+---------+-------------------+-------------------+---------------+----------------+
| 11 |
winda | jogja | 10 | 9876 | winda@gmail.com | 0000-00-00 | 1 | 2 |
| 12 |
ayu | bantul | 20 | 9999 | ayu@yahoo.com | 0000-00-00 | 2
| 1 |
| 13 |
rhiza | sleman | 30 | 8888 | rhiza@gmail.com | 0000-00-00 | 1 | 2 |
| 14 |
mitha | solo | 40 | 8765 | mitha@yahoo.co.id | 0000-00-00 | 2 | 1 |
| 15 |
anto | klaten | 50 | 6543 | anto@yahoo.com | 0000-00-00 | 1 | 2 |
+--------------+--------------+--------+----------------+---------+-------------------+-------------------+---------------+----------------+
5 rows in set (0.00 sec)
mysql> insert into bidang
values(‘1’,’sastra’),(‘2’,’sejarah’),(‘3’,’ilmu’),(‘4’,’kreatifitas’),(‘5’,’budaya’);
Query OK, 5 rows affected (0.08 sec)
Records: 5
Duplicates: 0 Warnings: 0
mysql> select * from bidang;
+-------------+-------------+
| kode_bidang | nama_bidang |
+-------------+-------------+
| 1 |
sastra |
| 2 |
sejarah |
| 3 |
ilmu |
| 4 | kreatifitas |
| 5 |
budaya |
+-------------+-------------+
5 rows in set (0.00 sec)
mysql> insert into buku values('61','harry
potter','1111','1','21','9','3','1',’123','1999','150','2','1','1'),('62','cinderella','1112','2','22','8','2','2','234','2000','135','4','2',
'1'),('63','love
story','1113','3','23','7','4','1','345','2001','120','2','3','1'),('64','upin-ipin','1114','4','24','6','1','2','456','2002','100','4','4','1'),('65','borobudur','1115
','5','25','5','4','1','567','2003','90','5','5','1');
Query OK, 5 rows affected (0.05 sec)
Records: 5
Duplicates: 0 Warnings: 0
mysql> select * from buku;
+-----------+--------------+-----------------+-------------+--------------+---------------+--------+--------+------+-------+----------------+-------+------------+--------+
| kode_buku | judul_buku
| kode_jenis_buku | kode_bidang | kode_penulis | kode_penerbit | jumlah
| bahasa | isbn | tahun | jumlah_halaman | edisi | cetakan_ke | status |
+-----------+--------------+-----------------+-------------+--------------+---------------+--------+--------+------+-------+----------------+-------+------------+--------+
| 61 | harry
potter | 1111 | 1 | 21 | 9 | 3 | 1
| 123 | 1999 | 150 | 2 | 1 | 1 |
| 62 |
cinderella | 1112 | 2 | 22 | 8 | 2 | 2
| 234 | 2000 |
135 | 4 | 2 | 1 |
| 63 | love
story | 1113 | 3 | 23 | 7 | 4 | 1
| 345 | 2001 |
120 | 2 | 3 | 1 |
| 64 |
upin-ipin | 1114 | 4 | 24 | 6 | 1 | 2
| 456 | 2002 |
100 | 4 | 4 | 1 |
| 65 |
borobudur | 1115 | 5 | 25 | 5 | 4 | 1
| 567 | 2003 |
90 | 5 | 5 | 1 |
+-----------+--------------+-----------------+-------------+--------------+---------------+--------+--------+------+-------+----------------+-------+------------+--------+
5 rows in set (0.00 sec)
mysql> load data local infile 'D:\pinjam.txt' into
table pinjam;
Query OK, 5 rows affected (0.06 sec)
Records: 5
Deleted: 0 Skipped: 0 Warnings: 0
mysql> select* from pinjam;
+-------------+--------------+-----------+----------------+-----------------------+
| kode_pinjam | kode_anggota | kode_buku | tanggal_pinjam
| tanggal_harus_kembali |
+-------------+--------------+-----------+----------------+-----------------------+
| 91 |
11 | 61 | 0000-00-00 | 0000-00-00 |
| 91 |
11 | 61 | 2013-01-05 | 2013-01-08 |
| 92 |
12 | 62 | 2013-01-06 | 2013-01-14 |
| 93 |
13 | 63 | 2013-01-07 | 2013-01-15 |
| 94 |
14 | 64 | 2013-01-08 | 2013-01-16 |
| 95 | 15 | 65 | 2013-01-09 | 2013-01-12 |
+-------------+--------------+-----------+----------------+-----------------------+
6 rows in set (0.01 sec)
mysql> load data local infile 'D:\hilang.txt' into
table bayar_hilang;
Query OK, 5 rows affected (0.06 sec)
Records: 5
Deleted: 0 Skipped: 0 Warnings: 0
mysql> select* from bayar_hilang;
+-------------+--------------+-----------+----------------+---------------+--------------+
| kode_pinjam | kode_anggota | kode_buku | tanggal_pinjam
| tanggal_bayar | jumlah_denda |
+-------------+--------------+-----------+----------------+---------------+--------------+
| 91 |
11 | 61 | 2013-01-05 | 2013-01-20 |
2 |
| 92 |
12 | 62
| 2013-01-06 | 2013-01-21 |
3 |
| 93 |
13 | 63 | 2013-01-07 | 2013-01-22 |
4 |
| 94 |
14 | 64 | 2013-01-08 | 2013-01-23 |
5 |
| 95 | 15 | 65 | 2013-01-09 | 2013-01-24 |
1 |
+-------------+--------------+-----------+----------------+---------------+--------------+
5 rows in set (0.00 sec)
mysql> load data local infile 'E:\kembali.txt' into
table kembali;
Query OK, 5 rows affected, 10 warnings (0.08 sec)
Records: 5
Deleted: 0 Skipped: 0 Warnings: 10
mysql> select* from kembali;
+-------------+--------------+--------------+-----------+----------------+-----------------+
| kode_pinjam | kode_kembali | kode_anggota | kode_buku |
tanggal_pinjam | tanggal_kembali |
+-------------+--------------+--------------+-----------+----------------+-----------------+
| 91 |
81 | 11 | 61 | 2013-01-05 | 2013-01-08 |
| 92 |
82 | 12 | 62 | 2013-01-06 | 2013-01-14 |
| 93 |
83 | 13 | 63 | 2013-01-07 | 2013-01-15 |
| 94 |
84 | 14 | 64 | 2013-01-08 | 2013-01-16 |
| 95 |
85 | 15 | 65 | 2013-01-09 | 2013-01-12 |
+-------------+--------------+--------------+-----------+----------------+-----------------+
5 rows in set (0.00 sec)
No
3.
mysql> select sum(jumlah) from buku;
+-------------+
| sum(jumlah) |
+-------------+
| 14 |
+-------------+
1 row in set (0.01 sec)
No.
4
mysql> select judul_buku, nama_penerbit from buku
order by judul_buku;
+--------------+---------------+
| judul_buku |
nama_penerbit |
+--------------+---------------+
| borobudur |
faisal |
| cinderella |
alfian |
| harry potter | budi |
| love story |
ayudha |
| upin-ipin |
farida |
+--------------+---------------+
5 rows in set (0.00 sec)
No. 5
mysql> select nama_anggota,tanggal_pinjam from pinjam order by
tanggal_pinjam;
+--------------+----------------+
| nama_anggota | tanggal_pinjam |
+--------------+----------------+
| winda | 0000-00-00 |
| winda | 2013-01-05 |
| ayu | 2013-01-06 |
| rhiza | 2013-01-07 |
| mitha | 2013-01-08 |
| anto | 2013-01-09 |
+--------------+----------------+
6 rows in set (0.01 sec)
No. 6
mysql> select tanggal_pinjam, tanggal_kembali, nama_anggota from kembali
order by nama_anggota;
+----------------+-----------------+--------------+
| tanggal_pinjam | tanggal_kembali | nama_anggota |
+----------------+-----------------+--------------+
| 2013-01-09 | 2013-01-12 | anto |
| 2013-01-06 | 2013-01-14 | ayu |
| 2013-01-08 | 2013-01-16 | mitha |
| 2013-01-07 | 2013-01-15 | rhiza |
| 2013-01-05 | 2013-01-08 | winda |
+----------------+-----------------+--------------+
5 rows in set (0.01 sec)
Tidak ada komentar:
Posting Komentar