From f8f03dc847ce15f70a230f12a41a2348e38e4812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8F=91=E6=A7=90?= <11785178+wmm1004lsp@user.noreply.gitee.com> Date: Sun, 10 Sep 2023 14:57:21 +0000 Subject: [PATCH 1/2] =?UTF-8?q?52=20=E7=8E=8B=E5=8F=91=E6=A7=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王发槐 <11785178+wmm1004lsp@user.noreply.gitee.com> --- ...\344\271\235\346\234\2109 \345\217\267.md" | 106 +++++++++++++++++ ...07\346\234\254\346\226\207\346\241\243.md" | 110 ++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 "52 \347\216\213\345\217\221\346\247\220/\344\271\235\346\234\2109 \345\217\267.md" create mode 100644 "52 \347\216\213\345\217\221\346\247\220/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.md" diff --git "a/52 \347\216\213\345\217\221\346\247\220/\344\271\235\346\234\2109 \345\217\267.md" "b/52 \347\216\213\345\217\221\346\247\220/\344\271\235\346\234\2109 \345\217\267.md" new file mode 100644 index 0000000..31f171c --- /dev/null +++ "b/52 \347\216\213\345\217\221\346\247\220/\344\271\235\346\234\2109 \345\217\267.md" @@ -0,0 +1,106 @@ +```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; +``` + diff --git "a/52 \347\216\213\345\217\221\346\247\220/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.md" "b/52 \347\216\213\345\217\221\346\247\220/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.md" new file mode 100644 index 0000000..8c16876 --- /dev/null +++ "b/52 \347\216\213\345\217\221\346\247\220/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.md" @@ -0,0 +1,110 @@ +```sql +CREATE DATABASE nb; +use nb; +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023-09-08 16:36:15 */ +/*==============================================================*/ + + +drop table if exists class; + +drop table if exists kecheng; + +drop table if exists major; + +drop table if exists school; + +drop table if exists student; + +drop table if exists teacher; + +/*==============================================================*/ +/* Table: class */ +/*==============================================================*/ +create table class +( + class_name char(4) not null, + class_id varchar(6) not null, + major_id varchar(10), + teacher_id char(4), + primary key (class_id) +); + +/*==============================================================*/ +/* Table: kecheng */ +/*==============================================================*/ +create table kecheng +( + teacher_id char(4) not null, + student_id int not null, + time varchar(11) not null, + adress varchar(11) not null, + primary key (teacher_id, student_id) +); + +/*==============================================================*/ +/* Table: major */ +/*==============================================================*/ +create table major +( + major_name char(10) not null, + major_id varchar(10) not null, + school_id varchar(4), + primary key (major_id) +); + +/*==============================================================*/ +/* Table: school */ +/*==============================================================*/ +create table school +( + school_name char(10) not null, + school_id varchar(4) not null, + primary key (school_id) +); + +/*==============================================================*/ +/* Table: student */ +/*==============================================================*/ +create table student +( + student_id int(3) not null auto_increment, + class_id varchar(6), + student_name varchar(4) not null, + student_garden char(10) not null, + primary key (student_id) +); + +/*==============================================================*/ +/* Table: teacher */ +/*==============================================================*/ +create table teacher +( + teacher_name varchar(6) not null, + teacher_id char(4) not null, + teacher_phone varchar(11) not null, + primary key (teacher_id) +); + +alter table class add constraint FK_Relationship_6 foreign key (teacher_id) + references teacher (teacher_id) on delete restrict on update restrict; + +alter table class add constraint FK_youyong foreign key (major_id) + references major (major_id) on delete restrict on update restrict; + +alter table kecheng add constraint FK_kecheng foreign key (teacher_id) + references teacher (teacher_id) on delete restrict on update restrict; + +alter table kecheng add constraint FK_kecheng2 foreign key (student_id) + references student (student_id) on delete restrict on update restrict; + +alter table major add constraint FK_yongyou foreign key (school_id) + references school (school_id) on delete restrict on update restrict; + +alter table student add constraint FK_shuyu foreign key (class_id) + references class (class_id) on delete restrict on update restrict; + + +``` + -- Gitee From 65aa71120c33beac349469d9b2e72f9d30fc99c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8F=91=E6=A7=90?= <11785178+wmm1004lsp@user.noreply.gitee.com> Date: Sun, 10 Sep 2023 14:57:48 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=2052?= =?UTF-8?q?=20=E7=8E=8B=E5=8F=91=E6=A7=90/=E6=96=B0=E5=BB=BA=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=96=87=E6=A1=A3.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...07\346\234\254\346\226\207\346\241\243.md" | 110 ------------------ 1 file changed, 110 deletions(-) delete mode 100644 "52 \347\216\213\345\217\221\346\247\220/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.md" diff --git "a/52 \347\216\213\345\217\221\346\247\220/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.md" "b/52 \347\216\213\345\217\221\346\247\220/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.md" deleted file mode 100644 index 8c16876..0000000 --- "a/52 \347\216\213\345\217\221\346\247\220/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.md" +++ /dev/null @@ -1,110 +0,0 @@ -```sql -CREATE DATABASE nb; -use nb; -/*==============================================================*/ -/* DBMS name: MySQL 5.0 */ -/* Created on: 2023-09-08 16:36:15 */ -/*==============================================================*/ - - -drop table if exists class; - -drop table if exists kecheng; - -drop table if exists major; - -drop table if exists school; - -drop table if exists student; - -drop table if exists teacher; - -/*==============================================================*/ -/* Table: class */ -/*==============================================================*/ -create table class -( - class_name char(4) not null, - class_id varchar(6) not null, - major_id varchar(10), - teacher_id char(4), - primary key (class_id) -); - -/*==============================================================*/ -/* Table: kecheng */ -/*==============================================================*/ -create table kecheng -( - teacher_id char(4) not null, - student_id int not null, - time varchar(11) not null, - adress varchar(11) not null, - primary key (teacher_id, student_id) -); - -/*==============================================================*/ -/* Table: major */ -/*==============================================================*/ -create table major -( - major_name char(10) not null, - major_id varchar(10) not null, - school_id varchar(4), - primary key (major_id) -); - -/*==============================================================*/ -/* Table: school */ -/*==============================================================*/ -create table school -( - school_name char(10) not null, - school_id varchar(4) not null, - primary key (school_id) -); - -/*==============================================================*/ -/* Table: student */ -/*==============================================================*/ -create table student -( - student_id int(3) not null auto_increment, - class_id varchar(6), - student_name varchar(4) not null, - student_garden char(10) not null, - primary key (student_id) -); - -/*==============================================================*/ -/* Table: teacher */ -/*==============================================================*/ -create table teacher -( - teacher_name varchar(6) not null, - teacher_id char(4) not null, - teacher_phone varchar(11) not null, - primary key (teacher_id) -); - -alter table class add constraint FK_Relationship_6 foreign key (teacher_id) - references teacher (teacher_id) on delete restrict on update restrict; - -alter table class add constraint FK_youyong foreign key (major_id) - references major (major_id) on delete restrict on update restrict; - -alter table kecheng add constraint FK_kecheng foreign key (teacher_id) - references teacher (teacher_id) on delete restrict on update restrict; - -alter table kecheng add constraint FK_kecheng2 foreign key (student_id) - references student (student_id) on delete restrict on update restrict; - -alter table major add constraint FK_yongyou foreign key (school_id) - references school (school_id) on delete restrict on update restrict; - -alter table student add constraint FK_shuyu foreign key (class_id) - references class (class_id) on delete restrict on update restrict; - - -``` - -- Gitee