CREATE DATABASE MY_DB
GO
USE MY_DB
CREATE TABLE TSUPPLIER(
KD_SUPPLIER VARCHAR(5) NOT NULL PRIMARY KEY,
NAMA_SUPPLIER VARCHAR(35) NOT NULL,
ALAMAT VARCHAR(35) NOT NULL)
CREATE TABLE TBARANG(
KD_BARANG VARCHAR(5) NOT NULL PRIMARY KEY,
NAMA_BARANG VARCHAR(35) NOT NULL,
HARGA_BARANG INT NOT NULL,
STOK INT NOT NULL,
KD_SUPPLIER VARCHAR(5) NOT NULL FOREIGN KEY REFERENCES TSUPPLIER(KD_SUPPLIER))
CREATE TABLE TBELI(
KD_BELI VARCHAR(5) NOT NULL PRIMARY KEY,
TGLBELI DATE NOT NULL,
KD_BARANG VARCHAR(5) NOT NULL FOREIGN KEY REFERENCES TBARANG(KD_BARANG),
JUMLAH_BELI INT)
CREATE TABLE STOK_ULANG(
KD_SU VARCHAR(5) NOT NULL PRIMARY KEY,
KD_BARANG VARCHAR(5) NOT NULL FOREIGN KEY REFERENCES TBARANG(KD_BARANG),
JUMLAH_SU INT) Sumber http://farihinmuhamad.blogspot.com