From 84899d4a2be49ff90d92f0bc9e8f048c3215ef56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?16=20=E9=98=99=E8=8B=8F=E6=96=87?= <2361635242@qq.com> Date: Mon, 11 Sep 2023 21:16:27 +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 --- ...41\347\220\206\347\263\273\347\273\237.md" | 134 ++++++++++++++++++ ...56\345\272\223\350\214\203\345\274\217.md" | 7 + 2 files changed, 141 insertions(+) create mode 100644 "16 \351\230\231\350\213\217\346\226\207/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" create mode 100644 "16 \351\230\231\350\213\217\346\226\207/\346\225\260\346\215\256\345\272\223\350\214\203\345\274\217.md" diff --git "a/16 \351\230\231\350\213\217\346\226\207/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" "b/16 \351\230\231\350\213\217\346\226\207/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" new file mode 100644 index 0000000..4d192ce --- /dev/null +++ "b/16 \351\230\231\350\213\217\346\226\207/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" @@ -0,0 +1,134 @@ +# 笔记 + +1、创建概念模型(类似ER图)CDM(用户角度) +2、转换成逻辑模型LDM(计算机角度) +3、转换成物理模型PDM(数据库角度) +4、生成DDL + +```mysql +/*==============================================================*/ +/* 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; + + +``` + diff --git "a/16 \351\230\231\350\213\217\346\226\207/\346\225\260\346\215\256\345\272\223\350\214\203\345\274\217.md" "b/16 \351\230\231\350\213\217\346\226\207/\346\225\260\346\215\256\345\272\223\350\214\203\345\274\217.md" new file mode 100644 index 0000000..50f4ab6 --- /dev/null +++ "b/16 \351\230\231\350\213\217\346\226\207/\346\225\260\346\215\256\345\272\223\350\214\203\345\274\217.md" @@ -0,0 +1,7 @@ +# 笔记 + +```mysql +范式1:要求字段的内容,不可在分割,位的是保证数据的原子性 +范式2:要求满足第一范式的基础上,要求非主键字段要求完全依赖主键(非主键,要依赖整个联合主键),而不能只依赖部分 +范式3:满足一、二范式的前提下,要求非主键属要直接依赖主键 +``` \ No newline at end of file -- Gitee