create database bms character set utf8mb4;
use bms;
create table user(
id int primary key auto_increment,
name varchar(20) not null unique,
state char(1) not null default 0);
create table book(
id int primary key auto_increment,
name varchar(20) not null unique,
price decimal(6,2) not null,
upload_time datetime not null,
borrow_id int,
borrow_time datetime,
state char(1)not null default 0);
create table record(
id int primary key auto_increment,
book_id int not null,
borrower_id int not null,
borrow_time datetime not null,
remand_time datetime not null);
insert into book values
('2001','C语言程序设计','23',now(),'1002',now(),'1'),
('2002','JAVA语言程序设计','18',now(),'2002',now(),'1'),
('2003','python语言程序设计','25',now(),'3002',now(),'1'),
('2004','CSS网页设计','34',now(),'4002',now(),'1');
insert into user values
('1','蔡徐坤','1'),
('2','孙笑川','1'),
('3','谷爱凌','1');
insert into record values
('1','1001','1001',now(),now()),
('2','2002','2002',now(),now()),
('3','3003','3003',now(),now()),
('4','4004','4004',now(),now());
DESC book;
DESC user;
DESC record;