TUGAS BASIS DATA LANJUT PENJUALAN



TUGAS BASIS DATA LANJUT
Nama              : Azis Maulana
NIM                : 8011010
Kelas               : TI 01
Semester         : V



Buatlah sebuah database di MySQL dengan nama PENJUALAN yang mempunyai tabel-tabel berikut:
INVENTORY
CREATE TABLE inventory (
kode_brg CHAR(5) NOT NULL,
nama_brg VARCHAR(30) NOT NULL,
jumlah DOUBLE NOT NULL,
harga_beli_satuan DOUBLE NOT NULL,
harga_jual­_satuanDOUBLE NOT NULL,
id_distributor CHAR(5) NOT NULL,
PRIMARY KEY(kode_brg),
FOREIGN KEY(id_distributor) REFERENCES distributor (id_distributor)
);
DISTRIBUTOR
CREATE TABLE distributor (
id_distributor CHAR(5) NOT NULL,
nama_distributor VARCHAR(30) NOT NULL,
alamat_distributor VARCHAR(35) NOT NULL,
telp_distributor VARCHAR(15) NOT NULL,
PRIMARY KEY(id_distributor)
);

JABATAN
CREATE TABLE jabatan (
id_jabatan CHAR(5) NOT NULL,
nama_jabatan VARCHAR(30) NOT NULL,
gaji DOUBLE NOT NULL,
PRIMARY KEY(id_jabatan)
);
PEGAWAI
CREATE TABLE pegawai (
id_pegawai CHAR(5) NOT NULL,
nama_pegawai VARCHAR(30) NOT NULL,
alamat_pegawai VARCHAR(35) NOT NULL,
telp_pegawai VARCHAR(15) NOT NULL,
jenis_kel CHAR(1) NOT NULL,
tanggal_masuk DATE NOT NULL default '0000-00-00',
id_jabatan CHAR(5) NOT NULL,
PRIMARY KEY(id_pegawai),
FOREIGN KEY(id_jabatan) REFERENCES jabatan (id_jabatan)
);
PEMBELIAN
CREATE TABLE pembelian (
no_nota_beli CHAR(5) NOT NULL,
tanggal_nota_beli DATE NOT NULL default '0000-00-00',
total_beli DOUBLE NOT NULL,
id_pegawai CHAR(5) NOT NULL,
PRIMARY KEY(no_nota_beli),
FOREIGN KEY(id_pegawai) REFERENCES pegawai (id_pegawai)
);
DETAIL PEMBELIAN
CREATE TABLE detailpembelian (
nota_detail_beli CHAR(5) NOT NULL,
jumlah_beli double NOT NULL,
harga_beli DOUBLE NOT NULL,
no_nota_beli CHAR(5) NOT NULL,
kode_brg CHAR(5) NOT NULL,
PRIMARY KEY(nota_detail_beli),
FOREIGN KEY(no_nota_beli) REFERENCES pembelian (no_nota_beli),
FOREIGN KEY(kode_brg) REFERENCES inventory (kode_brg)
);
PENJUALAN
CREATE TABLE penjualan (
no_nota_jual CHAR(5) NOT NULL,
tanggal_nota_jual DATE NOT NULL default '0000-00-00',
total_jual DOUBLE NOT NULL,
id_pegawai CHAR(5) NOT NULL,
PRIMARY KEY(no_nota_jual),
FOREIGN KEY(id_pegawai) REFERENCES pegawai (id_pegawai)
);
DETAIL PENJUALAN
CREATE TABLE detailpenjualan (
nota_detail_jual CHAR(5) NOT NULL,
jumlah_jual DOUBLE NOT NULL,
harga_jual DOUBLE NOT NULL,
no_nota_jual CHAR(5) NOT NULL,
kode_brg CHAR(5) NOT NULL,
PRIMARY KEY(nota_detail_jual),
FOREIGN KEY(no_nota_jual) REFERENCES penjualan (no_nota_jual),
FOREIGN KEY (kode_brg) REFERENCES inventory (kode_brg)
);



Silakan download untuk file lengkapnya disini
TUGAS BASIS DATA LANJUT PENJUALAN Rating: 4.5 Diposkan Oleh: Maulana Blog

No comments: