This repository has been archived on 2021-11-25. You can view files and clone it, but cannot push or open issues or pull requests.
DBHomework/setup.sql
kiritow d4ee2b3edb Update DBHomework.
And I'm gonna to sleep now.
2017-11-19 23:28:30 +08:00

96 lines
2.3 KiB
SQL

create table bs_meta_permission
(
permission_level integer primary key,
name varchar(10)
);
insert into bs_meta_permission values (0,'超级管理员'),(1,'管理员'),(2,'图书馆借阅处'),(3,'读者');
create table bs_meta_account
(
account_status integer primary key,
name varchar(10)
);
insert into bs_meta_account values (0,'隐藏'),(1,'禁止登陆'),(2,'待验证'),(3,'正常');
create table bs_meta_book
(
status integer primary key,
name varchar(10)
);
insert into bs_meta_book values (0,'隐藏'),(1,'禁用'),(2,'正常');
create table bs_meta_bookstatus
(
status integer primary key,
name varchar(10)
);
insert into bs_meta_bookstatus values (0,'借出'),(1,'丢失'),(2,'在馆');
create table bs_user
(
username varchar(10) primary key,
password char(32),
nickname varchar(10),
permission_level integer references bs_meta_permission(permission_level),
account_status integer references bs_meta_account(account_status)
);
create table bs_level
(
user_lv integer primary key,
min_amount_limit integer,
max_amount_limit integer,
min_time_limit integer,
max_time_limit integer,
min_balance decimal(10,2)
);
create table bs_reader
(
username varchar(10) references bs_user(username),
realname varchar(10),
realid char(18),
phonenum varchar(15),
user_lv integer references bs_level(user_lv),
user_exp integer,
borrow_limit integer,
borrow_used integer,
borrow_time_limit integer,
bonus integer,
balance decimal(10,2)
);
create table bs_booktype
(
book_type varchar(10) primary key
);
create table bs_book
(
class_id integer primary key,
isbn varchar(13) unique,
name varchar(20),
book_type varchar(10) references bs_booktype(book_type),
author varchar(10),
publisher varchar(20),
publish_time date,
status integer references bs_meta_book(status)
);
create table bs_bookstatus
(
book_id integer primary key,
class_id integer references bs_book(class_id),
position varchar(30),
status integer references bs_meta_bookstatus(status)
);
create table bs_borrow
(
username varchar(10) references bs_user(username),
book_id integer references bs_bookstatus(book_id),
borrow_time date not null,
return_deadline date not null,
return_time date
);
create table bs_session
(
id char(32) primary key,
last_time integer,
username varchar(10) references bs_user(username)
);