-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBusControlSystem.sql
More file actions
75 lines (62 loc) · 2.67 KB
/
BusControlSystem.sql
File metadata and controls
75 lines (62 loc) · 2.67 KB
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
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2018/12/6 15:05:45 */
/*==============================================================*/
drop table if exists Bus;
drop table if exists BusLine;
drop table if exists OneTurnTask;
drop table if exists User;
/*==============================================================*/
/* Table: Bus */
/*==============================================================*/
create table Bus
(
PlateNumber char(8) not null,
LineCode varchar(4),
BusState varchar(20) not null,
primary key (PlateNumber)
);
/*==============================================================*/
/* Table: BusLine */
/*==============================================================*/
create table BusLine
(
LineCode varchar(4) not null,
StartStation varchar(50) not null,
FinalStation varchar(50) not null,
primary key (LineCode)
);
/*==============================================================*/
/* Table: OneTurnTask */
/*==============================================================*/
create table OneTurnTask
(
LeaveTime0 int not null,
WorkDirection char(1) not null,
LineCode varchar(4),
PlateNumber char(8),
PredictTime int not null,
ArrivalTime0 int not null,
LeaveTime1 int,
ActualTime int,
ArrivalTime1 int,
WorkState char(1),
primary key (LeaveTime0, WorkDirection)
);
/*==============================================================*/
/* Table: User */
/*==============================================================*/
create table User
(
UserID int not null auto_increment,
Username varchar(50) not null,
Password varchar(18) not null,
EmailAddress varchar(50) not null,
primary key (UserID)
);
alter table Bus add constraint FK_Have foreign key (LineCode)
references BusLine (LineCode) on delete restrict on update restrict;
alter table OneTurnTask add constraint FK_Divide foreign key (LineCode)
references BusLine (LineCode) on delete restrict on update restrict;
alter table OneTurnTask add constraint FK_Workfor foreign key (PlateNumber)
references Bus (PlateNumber) on delete restrict on update restrict;