From b36113b93386b47577f8d9961d5879825012c4fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6?= <3228916049@qq.com> Date: Mon, 11 Sep 2023 04:02:02 +0000 Subject: [PATCH] =?UTF-8?q?9.8=E5=9B=BE=E4=B9=A6=E9=A6=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李舒汶 <3228916049@qq.com> --- ...06\346\225\260\346\215\256\345\272\223.md" | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 "49 \346\235\216\350\210\222\346\261\266/9.8\345\233\276\344\271\246\351\246\206\346\225\260\346\215\256\345\272\223.md" diff --git "a/49 \346\235\216\350\210\222\346\261\266/9.8\345\233\276\344\271\246\351\246\206\346\225\260\346\215\256\345\272\223.md" "b/49 \346\235\216\350\210\222\346\261\266/9.8\345\233\276\344\271\246\351\246\206\346\225\260\346\215\256\345\272\223.md" new file mode 100644 index 0000000..91c2944 --- /dev/null +++ "b/49 \346\235\216\350\210\222\346\261\266/9.8\345\233\276\344\271\246\351\246\206\346\225\260\346\215\256\345\272\223.md" @@ -0,0 +1,122 @@ +### 9.8笔记 + +第一步:创建概念模型(类似ER图) CDM (用户角度) +第二步:转换成逻辑模型 LDM (计算机角度) +第三步:转换成物理模型 PDM (数据库角度) +第四步:生成DDL + +### 数据库设计步骤 + +1.需求分析,了解要开发的系统的需求,明确数据和格式 +2.概念结构设计:将需求分析得到的抽象成概念模型,将ER图向关系模型转化 +3.逻辑结构设计:将概念结构转化成DBMS所支持的数据模型 +4.物理结构设计:将概念模型,转换成选定数据库管理系统需要的物理模型 +5.数据库实施:根据物理模型生成对应的DDL +6.数据库维护 + +#### 图书馆数据库 + +```java +CREATE DATABASE book charset utf8; +use book; +create table ad +( + A_id int not null, + L_name double not null, + A_password int not null, + primary key (A_id) +); + +/*==============================================================*/ +/* Table: books */ +/*==============================================================*/ +create table books +( + b_id int not null, + j_loan int not null, + time int not null, + b_name char(10) not null, + b_author char(10) not null, + b_press char(20) not null, + primary key (b_id) +); + +/*==============================================================*/ +/* Table: guanl */ +/*==============================================================*/ +create table guanl +( + st_id int not null, + j_loan int not null, + primary key (st_id, j_loan) +); + +/*==============================================================*/ +/* Table: jieyue */ +/*==============================================================*/ +create table jieyue +( + j_loan int not null, + j_also int not null, + primary key (j_loan) +); + +/*==============================================================*/ +/* Table: library */ +/*==============================================================*/ +create table library +( + L_name double not null, + st_id int not null, + primary key (L_name) +); + +/*==============================================================*/ +/* Table: manage */ +/*==============================================================*/ +create table manage +( + time int not null, + A_id int not null, + mode char(20) not null, + primary key (time) +); + +/*==============================================================*/ +/* Table: student */ +/*==============================================================*/ +create table student +( + st_id int not null, + L_name double not null, + st_name char(5) not null, + st_pa int not null, + st_sex char(1) not null, + primary key (st_id) +); + +alter table ad add constraint FK_yongyou5 foreign key (L_name) + references library (L_name) on delete restrict on update restrict; + +alter table books add constraint FK_guanl5 foreign key (time) + references manage (time) on delete restrict on update restrict; + +alter table books add constraint FK_guanli foreign key (j_loan) + references jieyue (j_loan) on delete restrict on update restrict; + +alter table guanl add constraint FK_guanl foreign key (st_id) + references student (st_id) on delete restrict on update restrict; + +alter table guanl add constraint FK_guanl2 foreign key (j_loan) + references jieyue (j_loan) on delete restrict on update restrict; + +alter table library add constraint FK_yongyou foreign key (st_id) + references student (st_id) on delete restrict on update restrict; + +alter table manage add constraint FK_yongy2 foreign key (A_id) + references ad (A_id) on delete restrict on update restrict; + +alter table student add constraint FK_yongyou2 foreign key (L_name) + references library (L_name) on delete restrict on update restrict; + +``` -- Gitee