JAM

v

Rabu, Februari 16, 2011

Database Rental

Sebelumnya q posting database perpustakaan,, skarang q postingin lagi database rental, semoga entitas-entitas ini cukup membantu,,

create database rental
use rental
create table motor
(no_motor char(10) not null,
nama_motor varchar(15) not null,
merk_motor varchar(15) not null,
tahun_keluar int not null,
biaya_sewa money
primary key(no_motor))
create table motor_inventaris
(no_inventaris char(10) not null,
no_motor char(10) not null,
no_polisi char(10)not null,
no_mesin char(10) not null,

primary key(no_inventaris),
constraint fk_mo foreign key(no_motor) references motor(no_motor))
create table pelanggan
(no_pelanggan char(10) not null,
nama_pelanggan varchar(30) not null,
alamat varchar(30)not null,
no_telp varchar(30) not null,
no_identitas varchar(30) not null,
primary key(no_pelanggan))

create table sewa
(no_sewa char(10) not null,
no_kembali char(10) notnull,
no_pelanggan char(10) not null,
no_inventaris char(10) not null,
jaminan varchar(30) not null,
tgl_sewa datetime

primary key(no_sewa),
constraint fk_pe foreign key (no_pelanggan) references pelanggan(no_pelanggan),
constraint fk_in foreign key(no_inventaris) references motor_inventaris(no_inventaris))

create table kembali
(no_kembali char(10)not null,
no_sewa char(10) not null,
denda money,
keterlambatan varchar(30) not null,
tgl_kembali datetime

primary key(no_kembali),
constraint fk_sewa foreign key (no_sewa) references sewa(no_sewa))

insert into motor values('01m','Jupiter-Z','Yamaha','2003','20000')
insert into motor values('02m','Jupiter-Z','Yamaha','2007','20000')
insert into motor values('03m','Ninja-RR','Kawasaki','2003','50000')
insert into motor values('04m','V-ixion','Yamaha','2009','50000')
insert into motor values('05m','Scorpio-Z','Yamaha','2009','50000')
insert into motor values('06m','Revo','Honda','2009','20000')
insert into motor values('07m','Smash','Susuki','2003','20000')
insert into kembali values('01k','01s','70000','Satu_Bulan','2010/03/01')
insert into kembali values('02k','02s','140000','Dua_Bulan','2010/04/07')
insert into kembali values('03k','03s','100000','Satu-Bulan','2010/08/02')
insert into kembali values('04k','04s','200000','Dua_Bulan','2010/09/09')
insert into kembali values('05k','05s','100000','Satu_Bulan','2010/07/03')
insert into kembali values('06k','06s','70000','Satu_Bulan','2010/05/06')
insert into kembali values('07k','07s','140000','Dua_Bulan','2010/04/03')
insert into motor_inventaris values('01mi','01m','R53421WK','ER1000')
insert into motor_inventaris values('02mi','02m','B34567UR','UI2000')
insert into motor_inventaris values('03mi','03m','D67895KO','OP3000')
insert into motor_inventaris values('04mi','04m','K98765IP','PO4000')
insert into motor_inventaris values('05mi','05m','L87645JK','KL5000')
insert into motor_inventaris values('06mi','06m','B87965YT','GR6000')
insert into motor_inventaris values('07mi','07m','H56789JH','YU7000')

insert into pelanggan values('01p','Adi','Jl.Mangga','0210000','i12345')
insert into pelanggan values('02p','Farhan','Jl.Kancil','0816789','i23456')
insert into pelanggan values('03p','Farhan','Jl.Semeru','08123456','i34567')
insert into pelanggan values('04p','Beoji','Jl.Beo','08167895','i45678')
insert into pelanggan values('05p','Abbas','Jl.Kelinci','08134256','i56789')
insert into pelanggan values('06p','Ariel','Jl.Sukarno','0818888','i67891')
insert into pelanggan values('07p','Luna','Jl.Jakarta','08189765','i78965')

insert into sewa values('01s','01p','01mi','Rumah','2010/01/01')
insert into sewa values('02s','02p','02mi','Mobil','2010/01/01')
insert into sewa values('03s','03p','03mi','Sertifikat_Tanah','2010/02/01')
insert into sewa values('04s','04p','04mi','MObil','2010/02/02')
insert into sewa values('05s','05p','05mi','Mobil','2010/04/07')
insert into sewa values('06s','06p','06mi','Rumah','2010/03/06')
insert into sewa values('07s','07p','07mi','Sertifikat_Tanah','2010/03/02')


Baca Selengkapnya......

Membuat Database Perpustakaan

What's up bro,,nih aq posting query buat database perpustakaan,, semoga ini bermanfaat,,,

Create database Perpustakaan
Use perpustakaan

create table Buku
(Kode_buku char(7)not null,
nama_buku varchar(20)not null,
jenis_buku varchar(20)not null,
judul_buku varchar(20)not null,
pengarang varchar(20)
primary key(Kode_buku))

create table Anggota
(Kode_anggota char(7)not null,
nama_anggota varchar(20)not null,
alamat varchar(20)not null,
no_telp varchar(20)not null,
kota varchar(20)not null,
primary key(Kode_anggota))

create table Pinjam
(No_pinjam char(7)not null,
Kode_anggota char(7)not null,
Kode_buku char(7)not null,
tgl_pinjam datetime,
tgl_kembali datetime,
constraint pk_Pin primary key(No_pinjam,Kode_anggota,Kode_buku),
constraint fk_kdanggota foreign key(Kode_anggota)references Anggota(Kode_anggota),
constraint fk_kdbuku foreign key(Kode_buku)references Buku(Kode_buku))

Mengisi Tabel

insert into buku values('01','diponegoro','sejarah','perjuangan','didik sugianto')
insert into buku values('02','diponegoro','sejarah','perjuangan','didik sugianto')
insert into buku values('03','uang','perekonomian','duit','helmi')

insert into anggota values('01','sugianto','jl.koe','99998','jakarta')
insert into anggota values('02','dani','jl.cileduk','098765','semarang')
insert into anggota values('03','dani','jl.mangga','08799','cilacap')

insert into pinjam values('1003001','01','01','2010/03/01','2010/03/10')
insert into pinjam values('1004002','02','02','2010/04/02','2010/04/11')
insert into pinjam values('1005003','03','03','2010/05/03','2010/05/12')


Baca Selengkapnya......