From cde784e1aed604b4bb4252b83a5add0f938ab188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=B8=85=E7=BF=94?= <3371439772@qq.com> Date: Mon, 11 Sep 2023 23:16:01 +0800 Subject: [PATCH] =?UTF-8?q?9=E6=9C=888=E6=97=A5=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crebas.sql" | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 "52\345\217\267 \347\250\213\345\270\205\347\277\224/crebas.sql" diff --git "a/52\345\217\267 \347\250\213\345\270\205\347\277\224/crebas.sql" "b/52\345\217\267 \347\250\213\345\270\205\347\277\224/crebas.sql" new file mode 100644 index 0000000..9125d3c --- /dev/null +++ "b/52\345\217\267 \347\250\213\345\270\205\347\277\224/crebas.sql" @@ -0,0 +1,122 @@ +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/11 22:59:04 */ +/*==============================================================*/ + + +drop table if exists Relationship_3; + +drop table if exists class; + +drop table if exists library; + +drop table if exists reader; + +drop table if exists student; + +drop table if exists "tea and stu"; + +drop table if exists teacher; + +/*==============================================================*/ +/* Table: Relationship_3 */ +/*==============================================================*/ +create table Relationship_3 +( + cl_id int not null, + tea_id int not null, + primary key (cl_id, tea_id) +); + +/*==============================================================*/ +/* Table: class */ +/*==============================================================*/ +create table class +( + cl_id int not null, + stu_id int not null, + cl_name char(10) not null, + primary key (cl_id) +); + +/*==============================================================*/ +/* Table: library */ +/*==============================================================*/ +create table library +( + li_id int not null, + li_name char(10) not null, + li_number char(11) not null, + primary key (li_id) +); + +/*==============================================================*/ +/* Table: reader */ +/*==============================================================*/ +create table reader +( + re_id varchar(110) not null, + li_id int not null, + re_name varchar(11) not null, + re_number varchar(11) not null, + primary key (re_id) +); + +/*==============================================================*/ +/* Table: student */ +/*==============================================================*/ +create table student +( + stu_id int not null, + li_id int not null, + stu_name char(10) not null, + stu_number char(11) not null, + primary key (stu_id) +); + +/*==============================================================*/ +/* Table: "tea and stu" */ +/*==============================================================*/ +create table "tea and stu" +( + stu_id int not null, + tea_id int not null, + primary key (stu_id, tea_id) +); + +/*==============================================================*/ +/* Table: teacher */ +/*==============================================================*/ +create table teacher +( + tea_id int not null, + li_id int not null, + tea_name char(10) not null, + tea_number char(11) not null, + primary key (tea_id) +); + +alter table Relationship_3 add constraint FK_Relationship_3 foreign key (cl_id) + references class (cl_id) on delete restrict on update restrict; + +alter table Relationship_3 add constraint FK_Relationship_4 foreign key (tea_id) + references teacher (tea_id) on delete restrict on update restrict; + +alter table class add constraint FK_xuexi foreign key (stu_id) + references student (stu_id) on delete restrict on update restrict; + +alter table reader add constraint FK_kehu foreign key (li_id) + references library (li_id) on delete restrict on update restrict; + +alter table student add constraint FK_jieyue foreign key (li_id) + references library (li_id) on delete restrict on update restrict; + +alter table "tea and stu" add constraint "FK_tea and stu" foreign key (stu_id) + references student (stu_id) on delete restrict on update restrict; + +alter table "tea and stu" add constraint "FK_tea and stu2" foreign key (tea_id) + references teacher (tea_id) on delete restrict on update restrict; + +alter table teacher add constraint FK_yonghu foreign key (li_id) + references library (li_id) on delete restrict on update restrict; + -- Gitee