diff --git "a/22 \350\202\226\351\222\237\345\207\257\351\237\251/20230907 \346\225\260\346\215\256\345\272\223\347\232\204\350\214\203\345\274\217.md" "b/22 \350\202\226\351\222\237\345\207\257\351\237\251/20230907 \346\225\260\346\215\256\345\272\223\347\232\204\350\214\203\345\274\217.md" new file mode 100644 index 0000000000000000000000000000000000000000..9cb5c46a7d304cb4fc14289300a6690a3c42bd18 --- /dev/null +++ "b/22 \350\202\226\351\222\237\345\207\257\351\237\251/20230907 \346\225\260\346\215\256\345\272\223\347\232\204\350\214\203\345\274\217.md" @@ -0,0 +1,19 @@ +## 数据库的范式 + +2023年9月7日 + +1.第一范式: + 要求字段的内容,不可再分割,为的是保证数据的原子性 + +2.第二范式: + +​ 要求在满足第一范式的基础上,要求非主键字段要完全依赖主键(非主键,要依赖整个联合主键)而不能只依赖部分 + +3.第三范式: + +​ 满足第二范式的前提上,要求,非主键属性要直接依赖于主键,而不能出现传递依赖 + +#### 注意 + +实际开发不会完全按照范式来设计,因为需求不一样,有时会故意反范式 + diff --git "a/22 \350\202\226\351\222\237\345\207\257\351\237\251/20230908 \346\225\260\346\215\256\343\200\201\351\200\273\350\276\221\343\200\201\347\211\251\347\220\206\346\250\241\345\236\213.md" "b/22 \350\202\226\351\222\237\345\207\257\351\237\251/20230908 \346\225\260\346\215\256\343\200\201\351\200\273\350\276\221\343\200\201\347\211\251\347\220\206\346\250\241\345\236\213.md" new file mode 100644 index 0000000000000000000000000000000000000000..799606b8575c7c43c3c33b7ce65393f3612102b0 --- /dev/null +++ "b/22 \350\202\226\351\222\237\345\207\257\351\237\251/20230908 \346\225\260\346\215\256\343\200\201\351\200\273\350\276\221\343\200\201\347\211\251\347\220\206\346\250\241\345\236\213.md" @@ -0,0 +1,158 @@ +## 数据、逻辑、物理模型 + +2023年9月8日 + +软件:PowerDesigner + +概念数据模型:CMD(Concept Data Model) + +逻辑数据模型:LDM(Logical Data Model) + +物理数据模型:PDM(Physical Data Model) + +#### 作用 + +1、概念数据模型 + +概念数据模型的目标是统一业务概念,作为业务人员和技术人员之间沟通的桥梁,确定不同实体之间的最高层次的关系 + +2、逻辑数据模型 + +逻辑模型是概念模型从真实世界向计算机世界的转换,加入了系统设计的相关内容。 + +3、物理数据模型 + +物理数据模型的目标是指定如何用具体的数据库模式来实现逻辑数据模型,以及真正的保存数据。 + +#### 步骤 + +第一步: + +​ 创建概念数据模型(E-R图)(以用户的角度) + +第二步: + +​ 转换成逻辑数据模型(LDM)(以计算机的角度)[快捷方式:Ctrl+shift+L] + +第三步: + +​ 转换成物理模型(PDM)(以数据库角度)[快捷方式:Ctrl+shift+P] + +第四步: + +​ 生成DDL[快捷方式:Ctrl+G] + + + + + +## 作业 + +~~~mysql + +create database books_01; +use books_01; + +drop table if exists Administrator; + +drop table if exists BookReturn; + +drop table if exists Borrow; + +drop table if exists books; + +drop table if exists bookshelf; + +drop table if exists borrower; + +drop table if exists floor; + +drop table if exists library; + + +create table Administrator +( + a_id int not null auto_increment, + l_id int not null, + a_job char(10) not null, + a_name char(5) not null, + a_age int not null, + a_sex char(1) not null, + a_tel char(11) not null, + primary key (a_id) +); + + +create table BookReturn +( + a_id int not null, + bor_id int not null, + bos_id int not null, + bo_id int not null, + f_id int not null, + ɕǚ date not null, + ʱݤ time not null +); + + +create table Borrow +( + bor_id int not null auto_increment, + bor_name char(5) not null, + bor_tel char(11) not null, + primary key (bor_id) +); + + +create table books +( + bos_id int not null auto_increment, + bo_id int not null, + bos_name char(20) not null, + bos_price decimal(5,2) not null, + bos_press char(10) not null, + primary key (bos_id) +); + +create table bookshelf +( + bo_id int not null auto_increment, + f_id int not null, + bo_name char(10) not null, + primary key (bo_id) +); + + +create table borrower +( + bos_id int not null, + bor_id int not null, + primary key (bos_id, bor_id) +); + + +create table floor +( + f_id int not null auto_increment, + l_id int not null, + f_floor int not null, + f_name char(10) not null, + primary key (f_id) +); + + +create table library +( + l_id int not null auto_increment, + l_name char(10) not null, + l_address varchar(50) not null, + l_p varchar(255) not null, + l_tel char(11) not null, + primary key (l_id) +); + + + +~~~ + +![img](https://s2.loli.net/2023/09/11/wusfkoh2pJimdLA.png)