diff --git "a/53 \345\276\220\345\205\210\351\221\253/2023.09.08 \346\246\202\345\277\265\346\250\241\345\236\213\357\274\214\351\200\273\350\276\221\346\250\241\345\236\213 \345\255\246\344\271\240.md" "b/53 \345\276\220\345\205\210\351\221\253/2023.09.08 \346\246\202\345\277\265\346\250\241\345\236\213\357\274\214\351\200\273\350\276\221\346\250\241\345\236\213 \345\255\246\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..f81f08c35f7ddaecf5f43b9ba76707479fbff85d --- /dev/null +++ "b/53 \345\276\220\345\205\210\351\221\253/2023.09.08 \346\246\202\345\277\265\346\250\241\345\236\213\357\274\214\351\200\273\350\276\221\346\250\241\345\236\213 \345\255\246\344\271\240.md" @@ -0,0 +1,125 @@ + + + + +2023年9月8日 + +星期五 + +概念模型 CDM、 + +逻辑模型 LDM 、 + +物理模型 PDM + + 三要素:1、实体:画矩形.里面写实体的各称 加下划线. + 属性:椭圆或圆形,里面写属性名称,用线条与实体直连,如果是主要性. +关系:用线条将两个实体相连,中间可以用菱形来表示之间联系,菱形可以当实付,也可有自己属性. + +```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; + + + +```