From 2dfaddfdf80f9b7f422d1d8d3d3aa1883ef94790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=83=9C=E6=9D=B0?= <2608607026@qq.com> Date: Mon, 11 Sep 2023 05:07:59 +0000 Subject: [PATCH] 2023-05-08 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈胜杰 <2608607026@qq.com> --- .../2023-05-08.md" | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 "58 \351\231\210\350\203\234\346\235\260/2023-05-08.md" diff --git "a/58 \351\231\210\350\203\234\346\235\260/2023-05-08.md" "b/58 \351\231\210\350\203\234\346\235\260/2023-05-08.md" new file mode 100644 index 0000000..ab76e8a --- /dev/null +++ "b/58 \351\231\210\350\203\234\346\235\260/2023-05-08.md" @@ -0,0 +1,112 @@ +笔记: + +1:powerDesigner: + +​ 第一步:创建概念模型(类似ER图) CDM (用户角度) + +​ 第二步:转换成逻辑模型 LDM (计算机角度) + +​ 第三步:转换成物理模型 PDM (数据库角度) + +​ 第四步:生成DDL + +2:数据库设计步骤: + +​ 1.需求分析,了解要开发的系统的需求,明确数据和格式 + +​ 2.概念结构设计:将需求分析得到的抽象成概念模型,将ER图向关系模型转化 + +​ 3.逻辑结构设计:将概念结构转化成DBMS所支持的数据模型 + +​ 4.物理结构设计:将概念模型,转换成选定数据库管理系统需要的物理模型 + +​ 5.数据库实施:根据物理模型生成对应的DDL + +​ 6.数据库维护 + +```mysql +drop table if exists` book; + +drop table if exists holding; + +drop table if exists library; + +drop table if exists record; + +drop table if exists student; + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + bk_id decimal not null, + bk_name char(20) not null, + bk_author char(10) not null, + ISBN int not null, + bk_date date not null, + bk_sort char(10) not null, + primary key (bk_id) +); + +/*==============================================================*/ +/* Table: holding */ +/*==============================================================*/ +create table holding +( + bk_id decimal not null, + lb_id decimal not null, + hd_id decimal not null, + primary key (bk_id, lb_id, hd_id) +); + +/*==============================================================*/ +/* Table: library */ +/*==============================================================*/ +create table library +( + lb_id decimal not null, + lb_name char(10) not null, + lb_address char(20) not null, + primary key (lb_id) +); + +/*==============================================================*/ +/* Table: record */ +/*==============================================================*/ +create table record +( + bk_id decimal not null, + stu_id decimal not null, + rc_id decimal not null, + primary key (bk_id, stu_id, rc_id) +); + +/*==============================================================*/ +/* Table: student */ +/*==============================================================*/ +create table student +( + stu_id decimal not null, + lb_id decimal not null, + stu_name char(10) not null, + stu_tel varchar(11) not null, + stu_address varchar(30) not null, + primary key (stu_id) +); + +alter table holding add constraint FK_Relationship_3 foreign key (bk_id) + references book (bk_id) on delete restrict on update restrict; + +alter table holding add constraint FK_Relationship_3 foreign key (lb_id) + references library (lb_id) on delete restrict on update restrict; + +alter table record add constraint FK_Relationship_1 foreign key (bk_id) + references book (bk_id) on delete restrict on update restrict; + +alter table record add constraint FK_Relationship_1 foreign key (stu_id) + references student (stu_id) on delete restrict on update restrict; + +alter table student add constraint FK_Relationship_2 foreign key (lb_id) + references library (lb_id) on delete restrict on update restrict; +``` \ No newline at end of file -- Gitee