DataPerpustakaan
1.0.0
This simple application is an example of implementing a database system. This application processes library data. The data will be stored in the perpus
database which contains several tables as follows, buku
, pengarang
, penerbit
, mahasiswa
, and peminjaman
.
Book Form Display
The following is the SQL code to create these tables:
-- Tabel Buku
CREATE TABLE buku (
judul VARCHAR ( 255 ),
genre ENUM( ' Agama ' , ' Fantasi ' , ' Filsafat ' , ' Pendidikan ' , ' Psikologi ' , ' Sains ' , ' Sejarah ' , ' Self-Improvement ' , ' Teknologi ' ),
ISBN VARCHAR ( 20 ) PRIMARY KEY ,
pengarang VARCHAR ( 255 ),
penerbit VARCHAR ( 255 ),
status_pinjam BOOLEAN
);
-- Tabel Pengarang
CREATE TABLE pengarang (
id_pengarang INT PRIMARY KEY AUTO_INCREMENT,
nama VARCHAR ( 255 ),
tanggal_lahir DATE ,
kebangsaan VARCHAR ( 100 )
);
-- Tabel Penerbit
CREATE TABLE penerbit (
id_penerbit INT PRIMARY KEY AUTO_INCREMENT,
nama VARCHAR ( 255 ),
kota VARCHAR ( 100 ),
website VARCHAR ( 255 ),
no_telp VARCHAR ( 20 )
);
-- Tabel Anggota (Mahasiswa)
CREATE TABLE mahasiswa (
NIM VARCHAR ( 9 ) PRIMARY KEY ,
nama VARCHAR ( 255 ),
fakultas ENUM( ' Ekonomi ' , ' FKIP ' , ' Hukum ' , ' Pertanian ' , ' Psikologi ' , ' Teknik ' ),
tanggal_lahir DATE ,
no_telp VARCHAR ( 20 )
);
-- Tabel Peminjaman
CREATE TABLE peminjaman (
id_pinjam INT PRIMARY KEY AUTO_INCREMENT,
ISBN VARCHAR ( 20 ),
NIM VARCHAR ( 9 ),
tanggal_pinjam DATE ,
tanggal_kembali DATE ,
status_kembali BOOLEAN ,
FOREIGN KEY (ISBN) REFERENCES buku(ISBN),
FOREIGN KEY (NIM) REFERENCES mahasiswa(NIM)
);
button
which have their respective functions, namely:Tambahkan
Tampilkan
Edit
Hapus
Cari
pengarang
field can only be filled in by authors who have been stored in the pengarang
table. If not, MessageBox
will appear commanding you to save new author data.penerbit
field.AVG
, COUNT
, MAX
, MIN
, SUM
) on anggota
formspeminjaman
table based on time (year, time and month)Cari
function will perform a query and then fill each TextBox
, DropDownList
, and RadioButtonList
form with valuesEdit
and Hapus
functions are performed after performing the Cari
function to make it more effective.Tambahkan
function on the Peminjaman
form status_kembali = 0
is the default . Then change status_pinjam
in the buku
table to status_pinjam = 1
.Buku Dipinjam
function in the Buku
form displays judul
( unique ), ISBN
, NIM
columns in the peminjaman
table and nama
based on NIM
in the mahasiswa
table using JOIN
. Data taken from the peminjaman
table is sorted by the latest tanggal_pinjam
. -- Join Tabel Buku, Peminjaman, dan Mahasiswa
SELECT buku . judul , buku . ISBN , mahasiswa . NIM , mahasiswa . nama , buku . status_pinjam
FROM buku
LEFT JOIN peminjaman ON buku . ISBN = peminjaman . ISBN
LEFT JOIN mahasiswa ON peminjaman . NIM = mahasiswa . NIM
WHERE Buku . status_pinjam = 1
AND ( peminjaman . ISBN , peminjaman . tanggal_pinjam )
IN ( SELECT ISBN, MAX (tanggal_pinjam) FROM peminjaman GROUP BY ISBN);
If you like or find this repository helpful, don't forget to give it a star