From 4e0860c3292c90d68f048b4b961b084bd11d7322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=96=87=E9=94=8B?= <2069827762@qq.com> Date: Mon, 11 Sep 2023 22:35:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...10\347\254\224\350\256\260\345\233\233.md" | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 "07 \345\210\230\346\226\207\351\224\213/20230910\347\254\224\350\256\260\345\233\233.md" diff --git "a/07 \345\210\230\346\226\207\351\224\213/20230910\347\254\224\350\256\260\345\233\233.md" "b/07 \345\210\230\346\226\207\351\224\213/20230910\347\254\224\350\256\260\345\233\233.md" new file mode 100644 index 0000000..28b4f3c --- /dev/null +++ "b/07 \345\210\230\346\226\207\351\224\213/20230910\347\254\224\350\256\260\345\233\233.md" @@ -0,0 +1,132 @@ +# 笔记 + +1、创建概念模型(类似ER图)CDM(用户角度) +2、转换成逻辑模型LDM(计算机角度) +3、转换成物理模型PDM(数据库角度) +4、生成DDL + +```java + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/11 14:58:55 */ +/*==============================================================*/ +CREATE database books charset utf8; +use books; + +drop table if exists administrators; + +drop table if exists author; + +drop table if exists book; + +drop table if exists bowor; + +drop table if exists press; + +drop table if exists readers; + +drop table if exists stack; + +/*==============================================================*/ +/* Table: administrators */ +/*==============================================================*/ +create table administrators +( + ad_id int not null, + ad_name char(10) not null, + ad_sex char(1) not null, + ad_duties char(10) not null, + primary key (ad_id) +); + +/*==============================================================*/ +/* Table: author */ +/*==============================================================*/ +create table author +( + auth_id int not null, + auth_wprks char(10) not null, + auth_price int not null, + primary key (auth_id) +); + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + bo_id int not null, + st_id int not null, + auth_id int not null, + pr_id int not null, + bo_name char(20) not null, + bo_price int not null, + bo_author char(10) not null, + primary key (bo_id) +); + +/*==============================================================*/ +/* Table: bowor */ +/*==============================================================*/ +create table bowor +( + re_id int not null, + bo_id int not null, + primary key (re_id, bo_id) +); + +/*==============================================================*/ +/* Table: press */ +/*==============================================================*/ +create table press +( + pr_id int not null, + pr_name char(10) not null, + pr_date date not null, + primary key (pr_id) +); + +/*==============================================================*/ +/* Table: readers */ +/*==============================================================*/ +create table readers +( + re_id int not null, + re_name char(20) not null, + re_age int not null, + re_sex char(1) not null, + primary key (re_id) +); + +/*==============================================================*/ +/* Table: stack */ +/*==============================================================*/ +create table stack +( + st_id int not null, + ad_id int not null, + st_address char(20) not null, + st_area int not null, + st_tel int not null, + primary key (st_id) +); + +alter table book add constraint FK_deposit foreign key (st_id) + references stack (st_id) on delete restrict on update restrict; + +alter table book add constraint FK_have foreign key (pr_id) + references press (pr_id) on delete restrict on update restrict; + +alter table book add constraint FK_work foreign key (auth_id) + references author (auth_id) on delete restrict on update restrict; + +alter table bowor add constraint FK_bowor foreign key (re_id) + references readers (re_id) on delete restrict on update restrict; + +alter table bowor add constraint FK_bowor2 foreign key (bo_id) + references book (bo_id) on delete restrict on update restrict; + +alter table stack add constraint FK_Relationship_5 foreign key (ad_id) + references administrators (ad_id) on delete restrict on update restrict; +``` \ No newline at end of file -- Gitee