diff --git "a/39 \351\203\255\346\202\246\350\277\216/202320908 \345\233\276\344\271\246\351\246\206\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\344\275\234\344\270\232.md" "b/39 \351\203\255\346\202\246\350\277\216/202320908 \345\233\276\344\271\246\351\246\206\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..20d7b8ab05413c6cd5b88c852e68782acba99f69 --- /dev/null +++ "b/39 \351\203\255\346\202\246\350\277\216/202320908 \345\233\276\344\271\246\351\246\206\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\344\275\234\344\270\232.md" @@ -0,0 +1,132 @@ +## 笔记 + +#### 使用**PowerDesigner** + +- 第一步:创建概念模型 CDM(类似E-R图)-----‘以用户的角度’ + +- 第二步:转换成逻辑模型 LDM -----‘以计算机的角度’ + +- 第三步:转换成物理模型 PDM -----(以数据库的角度) + +- 第四步:生成DDL + +------ + +## 单词注解 + +```mysql +1、entity 实体 + +2、inheritance 继承;传承 + +3、association 联合;联系 + +4、association link 连接线 + +5、general 综述;概要 + +6、indentifiers 标识符 + +7、cardinalities 基数 + +8、attributes 属性 + +9、mandatory 强制 +``` + + + +## 作业 + +```mysql +CREATE DATABASE Library charset utf8; +use Library; +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023-09-11 19:26:08 */ +/*==============================================================*/ + + +drop table if exists book; + +drop table if exists borrow; + +drop table if exists people; + +drop table if exists publish; + +drop table if exists type; + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + b_id int not null auto_increment, + pub_id int not null, + ty_id int not null, + b_name varchar(20) not null, + b_number varchar(10) not null, + b_address varchar(10) not null, + primary key (b_id) +); + +/*==============================================================*/ +/* Table: borrow */ +/*==============================================================*/ +create table borrow +( + p_id int not null, + b_id int not null, + primary key (p_id, b_id) +); + +/*==============================================================*/ +/* Table: people */ +/*==============================================================*/ +create table people +( + p_id int not null auto_increment, + p_name varchar(5) not null, + p_status varchar(5) not null, + primary key (p_id) +); + +/*==============================================================*/ +/* Table: publish */ +/*==============================================================*/ +create table publish +( + pub_id int not null auto_increment, + pub_name varchar(10) not null, + pub_tel varchar(11) not null, + pub_address varchar(20) not null, + pub_email varchar(20) not null, + primary key (pub_id) +); + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + ty_id int not null auto_increment, + ty_name varchar(10) not null, + primary key (ty_id) +); + +alter table book add constraint FK_come foreign key (pub_id) + references publish (pub_id) on delete restrict on update restrict; + +alter table book add constraint FK_sort foreign key (ty_id) + references type (ty_id) on delete restrict on update restrict; + +alter table borrow add constraint FK_borrow foreign key (p_id) + references people (p_id) on delete restrict on update restrict; + +alter table borrow add constraint FK_borrow2 foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + + +``` +