diff --git "a/47 \346\250\212\345\260\217\351\203\255/20230908 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\347\254\254\344\270\211\346\254\241\350\257\276\345\240\202\347\254\224\350\256\260.md" "b/47 \346\250\212\345\260\217\351\203\255/20230908 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\347\254\254\344\270\211\346\254\241\350\257\276\345\240\202\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..e1b0776b54ebc1c4e1c101c76cef9ec06fa4e20b --- /dev/null +++ "b/47 \346\250\212\345\260\217\351\203\255/20230908 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\347\254\254\344\270\211\346\254\241\350\257\276\345\240\202\347\254\224\350\256\260.md" @@ -0,0 +1,190 @@ +# 数据库高级第四次课堂笔记 + +### 数据库设计步骤 + +1.先做需求分析,明确需要的数据; + +2.概念结构设计:E-R图或PowerDesigner + +3.逻辑结构设计 + +4.物理结构设计 + +5.数据库的实施 + +6.数据库的维护 + + + +### E-R图补充说明: + +1.visio制作ER图的一个软件 + +2.三要素:实体、属性、关系 + +3.图形表示: + + 实体:矩形,里面写实体名称; + + 属性:圆形和椭圆,里面写属性名称,用直接与实体相连,如果是属性,名称下加下划线; + + 关系:用菱形表示,里面写联系,再用直线与两个实体相连,并标明实体之间关系(一对多) + + + +### 概念模型 + +一个软件:PowerDesigner + +第一步,创建概念模型(类似ER图)CDM(以用户的角度) + +第二步,转换成逻辑模型 LDM(以计算机角度) + +第三步,转换成物理模型 PDM(以数据库角度) + +第四步,生成DDL + + + +### PowerDesigner中的单词 + +PowerDesigner Sybase的企业建模和设计解决方案 + +File 文件夹 + +New Model 新型号 + +Model 模型 + +Model types 模型类型 + +Conceptual Data Model 概念数据模型 + +Entity 实体 + +Attributes... 属性 + +Identifiers... 标识符 + +Format...总体安排;计划 + +Change Image...电荷图像 + +Disposition 排列;布置 + +Order 命令;指示 + +Edit 编辑 + +Renam 改名 + +Properties 性能;性质 + + + +# 作业 + +创建一个图书管理系统 + +~~~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) +);