-
Notifications
You must be signed in to change notification settings - Fork 0
/
travlendar.sql
82 lines (67 loc) · 3.05 KB
/
travlendar.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 26/09/2017 07:30:06 */
/*==============================================================*/
drop table if exists DISTANCEMATRIX;
drop table if exists EVENT;
drop table if exists LOCATION;
drop table if exists TRAVELLER;
/*==============================================================*/
/* Table: DISTANCEMATRIX */
/*==============================================================*/
create table DISTANCEMATRIX
(
LOC_KODE_LOKASI int not null,
KODE_LOKASI int not null,
JARAK float,
primary key (LOC_KODE_LOKASI, KODE_LOKASI)
);
/*==============================================================*/
/* Table: EVENT */
/*==============================================================*/
create table EVENT
(
KODE_LOKASI int not null,
ID_EVENT bigint not null,
ID_TRAVELLER bigint not null,
NAMA_EVENT varchar(35),
ARRIVALTIME datetime,
DEPATURETIME datetime,
KDTRANSPORTATIONMODE smallint,
primary key (ID_TRAVELLER, KODE_LOKASI, ID_EVENT)
)
auto_increment = ID_EVENT;
/*==============================================================*/
/* Table: LOCATION */
/*==============================================================*/
create table LOCATION
(
KODE_LOKASI int not null,
NAMA_LOKASI varchar(25),
primary key (KODE_LOKASI)
)
auto_increment = KODE_LOKASI;
/*==============================================================*/
/* Table: TRAVELLER */
/*==============================================================*/
create table TRAVELLER
(
ID_TRAVELLER bigint not null,
KODE_LOKASI int,
USERNAME varchar(30),
EMAIL varchar(40),
PASSWORD varchar(255),
FULLNAME varchar(50),
primary key (ID_TRAVELLER)
)
auto_increment = ID_TRAVELLER;
alter table DISTANCEMATRIX add constraint FK_RELATIONSHIP_5 foreign key (LOC_KODE_LOKASI)
references LOCATION (KODE_LOKASI) on delete restrict on update restrict;
alter table DISTANCEMATRIX add constraint FK_RELATIONSHIP_6 foreign key (KODE_LOKASI)
references LOCATION (KODE_LOKASI) on delete restrict on update restrict;
alter table EVENT add constraint FK_RELATIONSHIP_7 foreign key (ID_TRAVELLER)
references TRAVELLER (ID_TRAVELLER) on delete restrict on update restrict;
alter table EVENT add constraint FK_RELATIONSHIP_8 foreign key (KODE_LOKASI)
references LOCATION (KODE_LOKASI) on delete restrict on update restrict;
alter table TRAVELLER add constraint FK_ALAMAT_RUMAH foreign key (KODE_LOKASI)
references LOCATION (KODE_LOKASI) on delete restrict on update restrict;