-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfind.sql
50 lines (43 loc) · 1.88 KB
/
find.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
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2015/11/7 11:16:30 */
/*==============================================================*/
drop table if exists record;
drop table if exists user;
/*==============================================================*/
/* Table: record */
/*==============================================================*/
create table record
(
id bigint not null auto_increment,
find_id bigint not null,
lost_id bigint not null,
time timestamp not null default CURRENT_TIMESTAMP,
status tinyint not null default 0,
way int,
token char(32),
primary key (id)
);
/*==============================================================*/
/* Table: user */
/*==============================================================*/
create table user
(
id bigint not null auto_increment,
yyid bigint,
number char(12),
school tinyint,
name varchar(10) not null,
phone char(16),
type tinyint,#标记用户类型0临时用户,-1无账号用户(失主),云印用户
blocked tinyint not null default 0,#关闭通知
status tinyint default 1,
primary key (id),
CONSTRAINT UNIQUE_CARD UNIQUE (school,number),#卡号唯一
UNIQUE(phone),#手机号唯一
UNIQUE(yyid)
);
alter table record add constraint FK_lost_user foreign key (lost_id)
references user (id) on delete restrict on update restrict;
alter table record add constraint FK_find_user foreign key (find_id)
references user (id) on delete restrict on update restrict;