From 373fa80b799f778e9b6fa4e7118c2455984a23d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=AE=8F=E8=BE=BE?= <2657224306@qq.com> Date: Mon, 11 Sep 2023 20:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=9C=E4=B9=9D=E6=9C=88=E5=8D=81=E4=B8=80?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../9\346\234\21011\346\227\245.md" | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 "48 \351\251\254\345\256\217\350\276\276/9\346\234\21011\346\227\245.md" diff --git "a/48 \351\251\254\345\256\217\350\276\276/9\346\234\21011\346\227\245.md" "b/48 \351\251\254\345\256\217\350\276\276/9\346\234\21011\346\227\245.md" new file mode 100644 index 0000000..320d25b --- /dev/null +++ "b/48 \351\251\254\345\256\217\350\276\276/9\346\234\21011\346\227\245.md" @@ -0,0 +1,113 @@ +drop table if exists administrators; + +drop table if exists book; + +drop table if exists "books category"; + +drop table if exists employee; + +drop table if exists faculties; + +drop table if exists student; + +drop table if exists 借书; + +/*==============================================================*/ +/* Table: administrators */ +/*==============================================================*/ +create table administrators +( + ad_id int not null, + em_id int not null, + ad_name char(20) not null, + ad_number char(20) not null, + primary key (ad_id) +); + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + bo_id int not null, + ca_id int not null, + bo_name varchar(20) not null, + primary key (bo_id) +); + +/*==============================================================*/ +/* Table: "books category" */ +/*==============================================================*/ +create table "books category" +( + ca_id int not null, + ad_id int not null, + ca_name char(20) not null, + primary key (ca_id) +); + +/*==============================================================*/ +/* Table: employee */ +/*==============================================================*/ +create table employee +( + em_id int not null, + ad_id int not null, + em_name char(20) not null, + primary key (em_id) +); + +/*==============================================================*/ +/* Table: faculties */ +/*==============================================================*/ +create table faculties +( + fa_id int not null, + fa_name varchar(20) not null, + fa_number char(20) not null, + primary key (fa_id) +); + +/*==============================================================*/ +/* Table: student */ +/*==============================================================*/ +create table student +( + stu_id int not null, + fa_id int not null, + stu_name varchar(20), + primary key (stu_id) +); + +/*==============================================================*/ +/* Table: 借书 */ +/*==============================================================*/ +create table 借书 +( + bo_id int not null, + stu_id int not null, + number int not null, + is_no int not null, + primary key (bo_id, stu_id) +); + +alter table administrators add constraint FK_ying foreign key (em_id) + references employee (em_id) on delete restrict on update restrict; + +alter table book add constraint FK_bao foreign key (ca_id) + references "books category" (ca_id) on delete restrict on update restrict; + +alter table "books category" add constraint FK_guan foreign key (ad_id) + references administrators (ad_id) on delete restrict on update restrict; + +alter table employee add constraint FK_dui foreign key (ad_id) + references administrators (ad_id) on delete restrict on update restrict; + +alter table student add constraint FK_shu foreign key (fa_id) + references faculties (fa_id) on delete restrict on update restrict; + +alter table 借书 add constraint FK_jie foreign key (stu_id) + references student (stu_id) on delete restrict on update restrict; + +alter table 借书 add constraint FK_jie1 foreign key (bo_id) + references book (bo_id) on delete restrict on update restrict; -- Gitee