Anda di halaman 1dari 3

create table kasir ( id_ksr char(4) not null, nama_ksr varchar2(15), almt_ksr nchar(15), constraint pk_kasir primary key

(id_ksr)); create table admin ( id_adm char(4) not null, nama_adm varchar2(15), almt_adm nchar(15), constraint pk_admin primary key (id_adm)); create table suplier ( id_sup char(4) not null, nama_sup varchar2(15), almt_sup nchar(15), constraint pk_suplier primary key (id_sup)); create table brg ( id_brg char(4) not null, nama_brg varchar2(15), hrg_brg nchar(15), constraint pk_brg primary key (id_brg)); create table penjualan ( id_penj char(4) not null, id_brg char(4) not null, id_ksr char(4) not null, jum_penj integer, constraint pk_penj primary key (id_penj), constraint fk_penj_brg foreign key (id_brg) references brg (id_brg), constraint fk_penj_ksr foreign key (id_ksr) references kasir (id_ksr)); create table pembelian ( id_pemb char(4) not null, id_brg char(4) not null, id_adm char(4) not null, id_sup char(4) not null, jum_pemb integer, constraint pk_pemb primary key constraint fk_pemb_brg foreign constraint fk_pemb_adm foreign constraint fk_pemb_sup foreign

(id_pemb), key (id_brg) references brg (id_brg), key (id_adm) references admin (id_adm), key (id_sup) references suplier (id_sup));

insert all into kasir values ('k001','zoe1','surabaya') into kasir values ('k002','zoe2','lamongan') select * from dual; insert all into admin values ('a001','tamam1','surabaya') into admin values ('a002','tamam2','lamongan') select * from dual; insert all into suplier values ('s001','suplier1','sidoarjo') into suplier values ('s002','suplier2','gresik') select * from dual; insert all

into brg values ('b001','besi',7000) into brg values ('b002','genteng',5000) select * from dual; insert all into penjualan values ('j001','b001','k002',100) into penjualan values ('j002','b001','k001',50) select * from dual; insert all into pembelian values ('t001','b001','a001','s001',500) into pembelian values ('t002','b002','a002','s001',100) select * from dual; create table kasirp ( id_ksrp char(4) not null, nama_ksrp varchar2(15), almt_ksrp nchar(15), constraint pk_kasirp primary key (id_ksrp)); create table adminp ( id_admp char(4) not null, nama_admp varchar2(15), almt_admp nchar(15), constraint pk_adminp primary key (id_admp)); create table kurirp ( id_kurirp char(4) not null, nama_kurirp varchar2(15), constraint pk_kurirp primary key (id_kurirp)); create table transaksip ( id_trans char(4) not null, id_ksrp char(4) not null, id_kurirp char(4) not null, nama_brg varchar2(15), brt_brg integer, constraint pk_trans primary key (id_trans), constraint fk_trans_ksr foreign key (id_ksrp) references kasirp (id_ksrp), constraint fk_trans_krr foreign key (id_kurirp) references kurirp (id_kurirp)); insert all into kasirp values ('k001','putri1','surabaya') into kasirp values ('k002','putri2','gresik') select * from dual; insert all into adminp values ('a001','tamam1','surabaya') into adminp values ('a002','tamam2','gresik') select * from dual; insert all into kurirp values ('r001','kurir1') into kurirp values ('r002','kurir2') select * from dual; insert all into transaksip values ('t001','k001','r001','baju',1) into transaksip values ('t002','k002','r002','sepatu',1)

select * from dual;