· 6 years ago · Oct 25, 2019, 04:58 PM
1alter table DETAIL_MENYEWA
2 drop foreign key FK_DETAIL_M_DETAIL_ME_FILM;
3
4alter table DETAIL_MENYEWA
5 drop foreign key FK_DETAIL_M_DETAIL_ME_MENYEWA;
6
7alter table FILM
8 drop foreign key FK_FILM_RELATIONS_KELOMPOK;
9
10alter table MENYEWA
11 drop foreign key FK_MENYEWA_RELATIONS_CUSTOMER;
12
13drop table if exists CUSTOMER;
14
15
16alter table DETAIL_MENYEWA
17 drop foreign key FK_DETAIL_M_DETAIL_ME_FILM;
18
19alter table DETAIL_MENYEWA
20 drop foreign key FK_DETAIL_M_DETAIL_ME_MENYEWA;
21
22drop table if exists DETAIL_MENYEWA;
23
24
25alter table FILM
26 drop foreign key FK_FILM_RELATIONS_KELOMPOK;
27
28drop table if exists FILM;
29
30drop index RELATIONSHIP_2_FK on KELOMPOK_FILM;
31
32drop table if exists KELOMPOK_FILM;
33
34
35alter table MENYEWA
36 drop foreign key FK_MENYEWA_RELATIONS_CUSTOMER;
37
38drop table if exists MENYEWA;
39
40/*==============================================================*/
41/* Table: CUSTOMER */
42/*==============================================================*/
43create table CUSTOMER
44(
45 NO_IDENTITAS char(3) not null,
46 KODE_SEWA char(5) not null,
47 JENIS_IDENTITAS varchar(10),
48 ALAMAT varchar(20),
49 primary key (NO_IDENTITAS)
50);
51
52/*==============================================================*/
53/* Table: DETAIL_MENYEWA */
54/*==============================================================*/
55create table DETAIL_MENYEWA
56(
57 KODE_FILM char(3) not null,
58 KODE_SEWA char(5) not null,
59 primary key (KODE_FILM, KODE_SEWA)
60);
61
62/*==============================================================*/
63/* Table: FILM */
64/*==============================================================*/
65create table FILM
66(
67 KODE_FILM char(3) not null,
68 JENIS_ID char(2) not null,
69 JUDUL varchar(50),
70 JML_KEPING int,
71 JML_FILM int,
72 primary key (KODE_FILM)
73);
74
75/*==============================================================*/
76/* Table: KELOMPOK_FILM */
77/*==============================================================*/
78create table KELOMPOK_FILM
79(
80 JENIS varchar(15),
81 HARGA_SEWA int,
82 JENIS_ID char(2) not null,
83 primary key (JENIS_ID)
84);
85
86/*==============================================================*/
87/* Index: RELATIONSHIP_2_FK */
88/*==============================================================*/
89create index RELATIONSHIP_2_FK on KELOMPOK_FILM
90(
91
92);
93
94/*==============================================================*/
95/* Table: MENYEWA */
96/*==============================================================*/
97create table MENYEWA
98(
99 KODE_SEWA char(5) not null,
100 NO_IDENTITAS char(3) not null,
101 TGL_SEWA date,
102 TOT_FILM int,
103 TGL_KEMBALI date,
104 TOT_HRG int,
105 DENDA int,
106 primary key (KODE_SEWA)
107);
108
109alter table DETAIL_MENYEWA add constraint FK_DETAIL_M_DETAIL_ME_FILM foreign key (KODE_FILM)
110 references FILM (KODE_FILM) on delete restrict on update restrict;
111
112alter table DETAIL_MENYEWA add constraint FK_DETAIL_M_DETAIL_ME_MENYEWA foreign key (KODE_SEWA)
113 references MENYEWA (KODE_SEWA) on delete restrict on update restrict;
114
115alter table FILM add constraint FK_FILM_RELATIONS_KELOMPOK foreign key (JENIS_ID)
116 references KELOMPOK_FILM (JENIS_ID) on delete restrict on update restrict;
117
118alter table MENYEWA add constraint FK_MENYEWA_RELATIONS_CUSTOMER foreign key (NO_IDENTITAS)
119 references CUSTOMER (NO_IDENTITAS) on delete restrict on update restrict;