diff --git "a/59 \351\231\210\345\256\207\350\276\211/\351\231\210\345\256\207\350\276\21120230908.md" "b/59 \351\231\210\345\256\207\350\276\211/\351\231\210\345\256\207\350\276\21120230908.md" new file mode 100644 index 0000000000000000000000000000000000000000..bc67ddef338eb56ca305db8970d39e5f1c4e3531 --- /dev/null +++ "b/59 \351\231\210\345\256\207\350\276\211/\351\231\210\345\256\207\350\276\21120230908.md" @@ -0,0 +1,157 @@ +**笔记** + +1.概念模型 CDM ER图,人类角度 + +2.逻辑模型 LDM 计算机 + +3.物理模型 PDM 从具体数据库角度 + +如何使用Typora自动上传图片 + +**作业** + +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/10 22:47:34 */ +/*==============================================================*/ +CREATE DATABASE school_library charset utf8; +use school_library; + +drop table if exists Administrator; + +drop table if exists book; + +drop table if exists fine; + +drop table if exists library; + +drop table if exists reader; + +drop table if exists registration; + +drop table if exists stack; + +/*==============================================================*/ +/* Table: Administrator */ +/*==============================================================*/ +create table Administrator +( + ad_id int not null auto_increment, + lib_id int, + ad_name char(4) not null, + ad_sex char(1) not null, + ad_tel char(11) not null, + primary key (ad_id) +); + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + b_id char(10) not null, + sta_id char(10), + b_name char(10) not null, + b_author char(10) not null, + b_press char(10) not null, + b_count char(10) not null, + primary key (b_id) +); + +/*==============================================================*/ +/* Table: fine */ +/*==============================================================*/ +create table fine +( + re_id int, + b_id char(10), + finedate char(11), + forfeit decimal(3,1), + cause char(30) +); + +/*==============================================================*/ +/* Table: library */ +/*==============================================================*/ +create table library +( + lib_id int not null auto_increment, + lib_name char(8) not null, + lib_tel char(11) not null, + lib_site char(15) not null, + primary key (lib_id) +); + +/*==============================================================*/ +/* Table: reader */ +/*==============================================================*/ +create table reader +( + re_id int not null auto_increment, + re_name char(4) not null, + re_xxt char(20) not null, + re_age char(3) not null, + re_college char(8) not null, + re_major char(8) not null, + re_grader int not null, + re_class char(4) not null, + primary key (re_id) +); + +/*==============================================================*/ +/* Table: registration */ +/*==============================================================*/ +create table registration +( + re_id int not null, + b_id char(10) not null, + ad_id int, + sta_id char(10), + Borrow char(11), + pdsrd char(11), + repayment char(11), + renew int, + primary key (re_id, b_id) +); + +/*==============================================================*/ +/* Table: stack */ +/*==============================================================*/ +create table stack +( + sta_id char(10) not null, + lib_id int, + sta_name char(10) not null, + primary key (sta_id) +); + +alter table Administrator add constraint FK_have foreign key (lib_id) + references library (lib_id) on delete restrict on update restrict; + +alter table book add constraint FK_Relationship_3 foreign key (sta_id) + references stack (sta_id) on delete restrict on update restrict; + +alter table fine add constraint FK_Relationship_8 foreign key (re_id, b_id) + references registration (re_id, b_id) on delete restrict on update restrict; + +alter table registration add constraint FK_Relationship_4 foreign key (re_id) + references reader (re_id) on delete restrict on update restrict; + +alter table registration add constraint FK_Relationship_5 foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + +alter table registration add constraint FK_Relationship_7 foreign key (sta_id) + references stack (sta_id) on delete restrict on update restrict; + +alter table registration add constraint FK_look foreign key (ad_id) + references Administrator (ad_id) on delete restrict on update restrict; + +alter table stack add constraint FK_Relationship_2 foreign key (lib_id) + references library (lib_id) on delete restrict on update restrict; + + +``` + + +