diff --git "a/55 \346\235\250\346\227\255\344\270\234/20230908\347\210\267\347\232\204\345\270\205\346\260\224\345\260\217\346\226\207\346\241\210.md" "b/55 \346\235\250\346\227\255\344\270\234/20230908\347\210\267\347\232\204\345\270\205\346\260\224\345\260\217\346\226\207\346\241\210.md" new file mode 100644 index 0000000000000000000000000000000000000000..6472c6412a7efadb9a6ec236187abcae9bd396b2 --- /dev/null +++ "b/55 \346\235\250\346\227\255\344\270\234/20230908\347\210\267\347\232\204\345\270\205\346\260\224\345\260\217\346\226\207\346\241\210.md" @@ -0,0 +1,113 @@ +~~~MySQL +2023.09.08 + 好像什么东西都会有一个保质期,秋刀鱼会过琪,我的idea也会过期,我在着过期的一天里,学到了什么powerdesigner,什么CDM,逻辑视图,物理视图,不错的,爱学的,待我好好琢磨一下。。。。。。 + + + + +```Mysql +/*==============================================================*/ +/* 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; +``` +~~~ +