diff --git "a/15 \345\220\264\346\226\214/20230908/.keep" "b/15 \345\220\264\346\226\214/20230908/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/15 \345\220\264\346\226\214/20230908/20230908 \346\227\245\345\277\227.md" "b/15 \345\220\264\346\226\214/20230908/20230908 \346\227\245\345\277\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..e872d097fcf4232a2ee6fb4b6c27752b767d8acd --- /dev/null +++ "b/15 \345\220\264\346\226\214/20230908/20230908 \346\227\245\345\277\227.md" @@ -0,0 +1,167 @@ +# 日志 + +## 九月八日 + +☀天 + +今天早上没课,下午复习了之前将的表与表的关系和三大范式,用到了一个新的软件叫“powerDesigner”,这个软件可以规划思路,之后直接将思路变为代码呈现出来。后面两节课就是自主练习。 + +晚上打排球🏐 + +# 代码 + +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/11 0:55:39 */ +/*==============================================================*/ +create database library charset utf8; + +use library; + +drop table if exists administration; + +drop table if exists administrator; + +drop table if exists book; + +drop table if exists borrow; + +drop table if exists location; + +drop table if exists student; + +drop table if exists type; + +/*==============================================================*/ +/* Table: administration */ +/*==============================================================*/ +create table administration +( + adm_id int not null, + bk_id int not null, + primary key (adm_id, bk_id) +); + +/*==============================================================*/ +/* Table: administrator */ +/*==============================================================*/ +create table administrator +( + adm_id int not null, + adm_name char(4) not null, + adm_sex char(1) not null, + adm_age int not null, + primary key (adm_id) +); + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + bk_id int not null, + ty_id int, + loc_id int, + bk_name char(10) not null, + bk_author char(10) not null, + bk_price int not null, + primary key (bk_id) +); + +/*==============================================================*/ +/* Table: borrow */ +/*==============================================================*/ +create table borrow +( + bk_id int not null, + stu_id int not null, + time date not null, + huanshu char(10) not null, + duration int not null, + primary key (bk_id, stu_id) +); + +/*==============================================================*/ +/* Table: location */ +/*==============================================================*/ +create table location +( + loc_id int not null, + loc_name char(3) not null, + loc_area char(10) not null, + primary key (loc_id) +); + +/*==============================================================*/ +/* Table: student */ +/*==============================================================*/ +create table student +( + stu_id int not null, + stu_name char(4) not null, + stu_sex char(1) not null, + stu_age int not null, + primary key (stu_id) +); + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + ty_id int not null, + ty_name char(10) not null, + primary key (ty_id) +); + +alter table administration add constraint FK_administration foreign key (adm_id) + references administrator (adm_id) on delete restrict on update restrict; + +alter table administration add constraint FK_administration2 foreign key (bk_id) + references book (bk_id) on delete restrict on update restrict; + +alter table book add constraint FK_type foreign key (ty_id) + references type (ty_id) on delete restrict on update restrict; + +alter table book add constraint FK_查找 foreign key (loc_id) + references location (loc_id) on delete restrict on update restrict; + +alter table borrow add constraint FK_borrow foreign key (bk_id) + references book (bk_id) on delete restrict on update restrict; + +alter table borrow add constraint FK_borrow2 foreign key (stu_id) + references student (stu_id) on delete restrict on update restrict; + +insert into student (stu_id, stu_name, stu_sex, stu_age) +values (1,'GG爆','男',18),(2,'菲菲','女',19),(3,'超人强','男',20); + +insert into type (ty_id, ty_name) +values (1,'热血'),(2,'学习'),(3,'爱情'),(4,'玄幻'),(5,'运动'); + +insert into administrator (adm_id, adm_name, adm_sex, adm_age) +values (1,'光头强','男',28),(2,'熊大','男',31),(3,'熊二','男',30); + +insert into location (loc_id, loc_name, loc_area) +values (1,'一层','文化类'),(2,'二层','小说类'),(3,'三层','体育类'); + +insert into book (bk_id, ty_id, loc_id, bk_name, bk_author, bk_price) +values (1,1,2,'斗破苍穹','天蚕土豆',128), + (2,2,1,'MySQL','黑马程序员',68), + (3,3,2,'坤坤爱上小黑子','坤坤总部',666), + (4,4,2,'重生之我变成了坤坤','坤坤总部',668), + (5,5,3,'闪电五连鞭','马保国',648); + +insert into administration (adm_id, bk_id) +values (1,1),(1,2),(2,3),(3,4),(2,5); + +insert into borrow (bk_id, stu_id, time, huanshu, duration) +values (1,1,'2023-09-01','9号',9), + (3,1,'2023-09-01','12号',12), + (4,1,'2023-09-01','15号',15), + (2,2,'2023-09-05','30号',26), + (1,2,'2023-09-02','25号',24), + (1,3,'2023-09-03','25号',23), + (5,3,'2023-09-04','25号',22); +``` + diff --git "a/15 \345\220\264\346\226\214/20230908/\345\276\256\344\277\241\345\233\276\347\211\207_20230911010758.png" "b/15 \345\220\264\346\226\214/20230908/\345\276\256\344\277\241\345\233\276\347\211\207_20230911010758.png" new file mode 100644 index 0000000000000000000000000000000000000000..8e7d83f2a24700d10c73ad1261394e2087aa586d Binary files /dev/null and "b/15 \345\220\264\346\226\214/20230908/\345\276\256\344\277\241\345\233\276\347\211\207_20230911010758.png" differ