From 44e263f5377896d87a4d5ed2a9f0308659cc432b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E4=BF=8A=E8=BD=B6?= <11785114+yejunyi@user.noreply.gitee.com> Date: Sun, 10 Sep 2023 14:56:00 +0000 Subject: [PATCH] =?UTF-8?q?=E5=8F=B6=E4=BF=8A=E8=BD=B6=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 叶俊轶 <11785114+yejunyi@user.noreply.gitee.com> --- .../20230908 \346\227\245\345\277\227.md" | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 "12 \345\217\266\344\277\212\350\275\266/20230908 \346\227\245\345\277\227.md" diff --git "a/12 \345\217\266\344\277\212\350\275\266/20230908 \346\227\245\345\277\227.md" "b/12 \345\217\266\344\277\212\350\275\266/20230908 \346\227\245\345\277\227.md" new file mode 100644 index 0000000..f44f931 --- /dev/null +++ "b/12 \345\217\266\344\277\212\350\275\266/20230908 \346\227\245\345\277\227.md" @@ -0,0 +1,114 @@ +2023年09月08日 + +周五 + +天气:咪咪雨 + +心情:OK + +明天是周末,什么powerdesigner,什么CDM,逻辑视图,物理视图,前面忘了,中间忘了,后面忘了,作业是图书馆数据库,还有个picgo,心情好不写了。 + +```sql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/10 22:21:34 */ +/*==============================================================*/ + + +drop table if exists Borrowing; + +drop table if exists UserId; + +drop table if exists book; + +drop table if exists dengji; + +drop table if exists jiyie; + +drop table if exists "return"; + +/*==============================================================*/ +/* Table: Borrowing */ +/*==============================================================*/ +create table Borrowing +( + brtime char(10) not null, + userid int(10) not null auto_increment, + username char(6) not null, + returntime date not null, + bokname char(5) not null, + bokid int(10) not null auto_increment, + primary key (userid, bokid) +); + +/*==============================================================*/ +/* Table: UserId */ +/*==============================================================*/ +create table UserId +( + user_id int(10) not null auto_increment, + user_name char(5) not null, + user_password char(6) not null, + primary key (user_id) +); + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + bk_id int(10) not null auto_increment, + bk_name char(10) not null, + primary key (bk_id) +); + +/*==============================================================*/ +/* Table: dengji */ +/*==============================================================*/ +create table dengji +( + bk_id int not null, + user_id int not null, + primary key (bk_id, user_id) +); + +/*==============================================================*/ +/* Table: jiyie */ +/*==============================================================*/ +create table jiyie +( + userid int not null, + bokid int not null, + user_id int not null, + primary key (userid, bokid, user_id) +); + +/*==============================================================*/ +/* Table: "return" */ +/*==============================================================*/ +create table "return" +( + userid int not null, + bokid int not null, + bk_id int not null, + primary key (userid, bokid, bk_id) +); + +alter table dengji add constraint FK_dengji foreign key (bk_id) + references book (bk_id) on delete restrict on update restrict; + +alter table dengji add constraint FK_dengji2 foreign key (user_id) + references UserId (user_id) on delete restrict on update restrict; + +alter table jiyie add constraint FK_jiyie foreign key (userid, bokid) + references Borrowing (userid, bokid) on delete restrict on update restrict; + +alter table jiyie add constraint FK_jiyie2 foreign key (user_id) + references UserId (user_id) on delete restrict on update restrict; + +alter table "return" add constraint FK_return foreign key (userid, bokid) + references Borrowing (userid, bokid) on delete restrict on update restrict; + +alter table "return" add constraint FK_return2 foreign key (bk_id) + references book (bk_id) on delete restrict on update restrict; +``` -- Gitee