From 5ea746cc97e48e87526d240990272d146a09cf50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AE=87=E8=BE=89?= <2696103916@qq.com> Date: Sun, 10 Sep 2023 15:03:05 +0000 Subject: [PATCH] =?UTF-8?q?=E9=99=88=E5=AE=87=E8=BE=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈宇辉 <2696103916@qq.com> --- ...31\210\345\256\207\350\276\21120230908.md" | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 "59 \351\231\210\345\256\207\350\276\211/\351\231\210\345\256\207\350\276\21120230908.md" 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 0000000..bc67dde --- /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; + + +``` + + + -- Gitee