作业要自己做,不懂的问我们,不会的可以学,学不会就去搬砖
创建数据库
create database if not exists libbookms;
创建数据库表https://blog.csdn.net/hyh17808770899/article/details/105048477
例如
create table if not exists student
(
studentno char(11) not null comment'学号',
sname char(8) not null comment'姓名',
sex enum('男', '女') default '男' comment'性别',
birthdate date not null comment'出生日期',
entrance int(3) null comment'入学成绩',
phone varchar(12) not null comment'电话',
Email varchar(20) not null comment'电子信箱',
primary key (studentno)
);
插入数据:https://blog.csdn.net/hyh17808770899/article/details/105080474
create database if not exists libbookms;
use libbookms;
create table if not exists books
(
bname varchar(50) not null,
author varchar(10) not null,
liberid varchar(20) not null,
publish varchar(30) not null,
price float(2) not null,
isfree varchar(2) not null,
primary key (liberid)
);
create table if not exists borrower
(
bwno varchar(20) not null,
name varchar(10) not null,
sex varchar(2) not null,
systems varchar(20) not null,
clazz varchar(10) not null,
primary key (bwno)
);
create table if not exists loans
(
bwno varchar(20) not null,
liberid varchar(20) not null,
bdate date not null,
rdate date default NULL,
foreign key (bwno) references borrower(bwno),
foreign key (liberid) references books(liberid)
);
insert into books (bname, author, liberid, publish, price, isfree) values
('数据结构', '李伟', 'T00101', '机械工业出版社', '32.00', 'N'),
('数据结构', '李伟', 'T00102', '机械工业出版社', '32.00', 'Y'),
('汇编语言', '张冲', 'T00201', '清华大学出版社', '78.00', 'Y'),
('数据通信', '杨志', 'T00301', '科学出版社', '45.00', 'Y'),
('企业自动化管理', '张恒', 'T00401', '清华大学出版社', '38.00', 'N');
insert into borrower (bwno, name, sex, systems, clazz) values
('03001', '赵磊', 'M', '自动化系', '10-1'),
('03002', '刘成', 'M', '自动化系', '10-1'),
('03003', '程玲', 'F', '自动化系', '10-2'),
('04001', '张克', 'M', '信息系', '11-1'),
('04002', '肖倩', 'F', '信息系', '11-2');
insert into loans (bwno, liberid, bdate, rdate) values
('03001', 'T00102', '2011-5-1', '2011-6-20'),
('03003', 'T00201', '2011-5-1', '2011-5-25'),
('03001', 'T00201', '2011-6-20', '2011-10-11'),
('03001', 'T00301', '2011-7-1', '2011-8-20'),
('04002', 'T00101', '2011-8-15', NULL),
('03003', 'T00102', '2011-9-1', NULL),
('03002', 'T00401', '2011-7-1', '2011-8-12'),
('04002', 'T00201', '2011-11-1', NULL);