-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.sql
More file actions
50 lines (45 loc) · 1.29 KB
/
table.sql
File metadata and controls
50 lines (45 loc) · 1.29 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
drop table plan_sheet;
drop table employee;
drop table device;
drop table plan;
drop table device_type;
create table device_type (
id int not null auto_increment primary key,
code varchar(128),
name varchar(255) not null,
description text
);
create table plan (
id int not null auto_increment primary key,
days int not null,
name enum('SMALL', 'MIDDLE', 'BIG') not null,
description text,
device_type_id int not null,
foreign key (device_type_id) references device_type(id)
);
create table device (
id int not null auto_increment primary key,
equip_time date not null,
location varchar(255) not null,
device_type_id int not null,
foreign key (device_type_id) references device_type(id)
);
create table employee (
id int not null auto_increment primary key,
name varchar(64) not null,
gender enum('M', 'F') not null,
age int not null
);
create table plan_sheet (
id int not null auto_increment primary key,
device_id int not null,
plan_id int not null,
state enum('WAITING', 'FINISHED', 'CANCELED') not null default 'WAITING',
should_do_time date not null,
do_time date default null,
employee_id int default null,
hours float default null,
foreign key (device_id) references device(id),
foreign key (plan_id) references plan(id),
foreign key (employee_id) references employee(id)
);