/*==============================================================*/ /* DBMS name: SAP SQL Anywhere 16 */ /* Created on: 23/04/2018 16.01.34 */ /*==============================================================*/ if exists(select 1 from sys.sysforeignkey where role='FK_BARANG_RELATIONS_JENIS_BA') then alter table BARANG delete foreign key FK_BARANG_RELATIONS_JENIS_BA end if; if exists(select 1 from sys.sysforeignkey where role='FK_BARANG_RELATIONS_SUPLIER') then alter table BARANG delete foreign key FK_BARANG_RELATIONS_SUPLIER end if; if exists(select 1 from sys.sysforeignkey where role='FK_DETAIL_T_RELATIONS_TRANSAKS') then alter table DETAIL_TRANSAKSI delete foreign key FK_DETAIL_T_RELATIONS_TRANSAKS end if; if exists(select 1 from sys.sysforeignkey where role='FK_DETAIL_T_RELATIONS_BARANG') then alter table DETAIL_TRANSAKSI delete foreign key FK_DETAIL_T_RELATIONS_BARANG end if; if exists(select 1 from sys.sysforeignkey where role='FK_TRANSAKS_RELATIONS_PELANGAN') then alter table TRANSAKSI delete foreign key FK_TRANSAKS_RELATIONS_PELANGAN end if; if exists(select 1 from sys.sysforeignkey where role='FK_TRANSAKS_RELATIONS_KARYAWAN') then alter table TRANSAKSI delete foreign key FK_TRANSAKS_RELATIONS_KARYAWAN end if; drop index if exists BARANG.RELATIONSHIP4_FK; drop index if exists BARANG.BARANG_PK; drop table if exists BARANG; drop index if exists DETAIL_TRANSAKSI.RELATIONSHIP6_FK; drop index if exists DETAIL_TRANSAKSI.RELATIONSHIP5_FK; drop index if exists DETAIL_TRANSAKSI.DETAIL_TRANSAKSI_PK; drop table if exists DETAIL_TRANSAKSI; drop index if exists JENIS_BARANG.JENIS_BARANG_PK; drop table if exists JENIS_BARANG; drop index if exists KARYAWAN.KARYAWAN_PK; drop table if exists KARYAWAN; drop index if exists PELANGAN.PELANGAN_PK; drop table if exists PELANGAN; drop index if exists SUPLIER.SUPLIER_PK; drop table if exists SUPLIER; drop index if exists TRANSAKSI.RELATIONSHIP2_FK; drop index if exists TRANSAKSI.RELATIONSHIP1_FK; drop index if exists TRANSAKSI.TRANSAKSI_PK; drop table if exists TRANSAKSI; /*==============================================================*/ /* Table: BARANG */ /*==============================================================*/ create table BARANG ( ID_JENIS_BRG varchar(254) not null, ID_SUPLIER varchar(254) null, ID_BARANG varchar(254) null, NAMA_BARANG varchar(254) null, STOK numeric null, HARGA numeric null, PERSEN_LABA numeric null, DISKON numeric null, constraint PK_BARANG primary key clustered (ID_JENIS_BRG) ); /*==============================================================*/ /* Index: BARANG_PK */ /*==============================================================*/ create unique clustered index BARANG_PK on BARANG ( ID_JENIS_BRG ASC ); /*==============================================================*/ /* Index: RELATIONSHIP4_FK */ /*==============================================================*/ create index RELATIONSHIP4_FK on BARANG ( ID_SUPLIER ASC ); /*==============================================================*/ /* Table: DETAIL_TRANSAKSI */ /*==============================================================*/ create table DETAIL_TRANSAKSI ( KODE_TRANSAKSI varchar(254) not null, TRA_KODE_TRANSAKSI varchar(254) null, ID_JENIS_BRG varchar(254) null, JUMLAH numeric null, constraint PK_DETAIL_TRANSAKSI primary key clustered (KODE_TRANSAKSI) ); /*==============================================================*/ /* Index: DETAIL_TRANSAKSI_PK */ /*==============================================================*/ create unique clustered index DETAIL_TRANSAKSI_PK on DETAIL_TRANSAKSI ( KODE_TRANSAKSI ASC ); /*==============================================================*/ /* Index: RELATIONSHIP5_FK */ /*==============================================================*/ create index RELATIONSHIP5_FK on DETAIL_TRANSAKSI ( TRA_KODE_TRANSAKSI ASC ); /*==============================================================*/ /* Index: RELATIONSHIP6_FK */ /*==============================================================*/ create index RELATIONSHIP6_FK on DETAIL_TRANSAKSI ( ID_JENIS_BRG ASC ); /*==============================================================*/ /* Table: JENIS_BARANG */ /*==============================================================*/ create table JENIS_BARANG ( ID_JENIS_BRG varchar(254) not null, NAMA_JENIS_BRG varchar(254) null, constraint PK_JENIS_BARANG primary key clustered (ID_JENIS_BRG) ); /*==============================================================*/ /* Index: JENIS_BARANG_PK */ /*==============================================================*/ create unique clustered index JENIS_BARANG_PK on JENIS_BARANG ( ID_JENIS_BRG ASC ); /*==============================================================*/ /* Table: KARYAWAN */ /*==============================================================*/ create table KARYAWAN ( ID_KARYAWAN varchar(254) not null, NAMA_KARYAWAN varchar(254) null, ALAMAT_KARYAWAN varchar(254) null, TELP_KARYAWAN numeric null, TGL_LAHIR_KARYAWAN timestamp null, GAJI numeric null, constraint PK_KARYAWAN primary key clustered (ID_KARYAWAN) ); /*==============================================================*/ /* Index: KARYAWAN_PK */ /*==============================================================*/ create unique clustered index KARYAWAN_PK on KARYAWAN ( ID_KARYAWAN ASC ); /*==============================================================*/ /* Table: PELANGAN */ /*==============================================================*/ create table PELANGAN ( ID_PELANGGAN varchar(254) not null, NAMA_PELANGGAN varchar(254) null, JENIS_KELAMIN varchar(254) null, ALAMAT_PELANGGAN varchar(254) null, TELP_PELANGGAN numeric null, TGL_LAHIR_PELANGGAN timestamp null, constraint PK_PELANGAN primary key clustered (ID_PELANGGAN) ); /*==============================================================*/ /* Index: PELANGAN_PK */ /*==============================================================*/ create unique clustered index PELANGAN_PK on PELANGAN ( ID_PELANGGAN ASC ); /*==============================================================*/ /* Table: SUPLIER */ /*==============================================================*/ create table SUPLIER ( ID_SUPLIER varchar(254) not null, NAMA_SUPLIER varchar(254) null, ALAMAT_SUPLIER varchar(254) null, TELP_SUPLIER numeric null, constraint PK_SUPLIER primary key clustered (ID_SUPLIER) ); /*==============================================================*/ /* Index: SUPLIER_PK */ /*==============================================================*/ create unique clustered index SUPLIER_PK on SUPLIER ( ID_SUPLIER ASC ); /*==============================================================*/ /* Table: TRANSAKSI */ /*==============================================================*/ create table TRANSAKSI ( KODE_TRANSAKSI varchar(254) not null, ID_KARYAWAN varchar(254) null, ID_PELANGGAN varchar(254) null, TGL_TRANSAKSI timestamp null, constraint PK_TRANSAKSI primary key clustered (KODE_TRANSAKSI) ); /*==============================================================*/ /* Index: TRANSAKSI_PK */ /*==============================================================*/ create unique clustered index TRANSAKSI_PK on TRANSAKSI ( KODE_TRANSAKSI ASC ); /*==============================================================*/ /* Index: RELATIONSHIP1_FK */ /*==============================================================*/ create index RELATIONSHIP1_FK on TRANSAKSI ( ID_PELANGGAN ASC ); /*==============================================================*/ /* Index: RELATIONSHIP2_FK */ /*==============================================================*/ create index RELATIONSHIP2_FK on TRANSAKSI ( ID_KARYAWAN ASC ); alter table BARANG add constraint FK_BARANG_RELATIONS_JENIS_BA foreign key (ID_JENIS_BRG) references JENIS_BARANG (ID_JENIS_BRG) on update restrict on delete restrict; alter table BARANG add constraint FK_BARANG_RELATIONS_SUPLIER foreign key (ID_SUPLIER) references SUPLIER (ID_SUPLIER) on update restrict on delete restrict; alter table DETAIL_TRANSAKSI add constraint FK_DETAIL_T_RELATIONS_TRANSAKS foreign key (TRA_KODE_TRANSAKSI) references TRANSAKSI (KODE_TRANSAKSI) on update restrict on delete restrict; alter table DETAIL_TRANSAKSI add constraint FK_DETAIL_T_RELATIONS_BARANG foreign key (ID_JENIS_BRG) references BARANG (ID_JENIS_BRG) on update restrict on delete restrict; alter table TRANSAKSI add constraint FK_TRANSAKS_RELATIONS_PELANGAN foreign key (ID_PELANGGAN) references PELANGAN (ID_PELANGGAN) on update restrict on delete restrict; alter table TRANSAKSI add constraint FK_TRANSAKS_RELATIONS_KARYAWAN foreign key (ID_KARYAWAN) references KARYAWAN (ID_KARYAWAN) on update restrict on delete restrict;