diff --git "a/09 \346\233\271\346\255\243\346\263\242/20230908 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247.md" "b/09 \346\233\271\346\255\243\346\263\242/20230908 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247.md" new file mode 100644 index 0000000000000000000000000000000000000000..f858ae9b87a0a1fa920bfd895222fe02e393cfac --- /dev/null +++ "b/09 \346\233\271\346\255\243\346\263\242/20230908 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247.md" @@ -0,0 +1,88 @@ +# 笔记 + +## 操作步骤 + +1.创建概念模型(E-R图) CDM + +2.转换成逻辑模型 LDM + +3.转换成物理模型 PDM + +4.生成DDL + + + +# 作业 + +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/10 19:49:40 */ +/*==============================================================*/ + + +drop table if exists Books; + +drop table if exists Borrowing; + +drop table if exists Borrowing2; + +drop table if exists publishinghouse; + +/*==============================================================*/ +/* Table: Books */ +/*==============================================================*/ +create table Books +( + bo_id varchar(20) not null, + pu_id varchar(10) not null, + bo_name varchar(10) not null, + bo_loc varchar(20) not null, + primary key (bo_id) +); + +/*==============================================================*/ +/* Table: Borrowing */ +/*==============================================================*/ +create table Borrowing +( + borr_id varchar(2) not null, + borr_name varchar(5) not null, + primary key (borr_id) +); + +/*==============================================================*/ +/* Table: Borrowing2 */ +/*==============================================================*/ +create table Borrowing2 +( + bo_id varchar(20) not null, + borr_id varchar(2) not null, + borr_date varchar(10) not null, + "Return" varchar(10) not null, + primary key (bo_id, borr_id, borr_date) +); + +/*==============================================================*/ +/* Table: publishinghouse */ +/*==============================================================*/ +create table publishinghouse +( + pu_id varchar(10) not null, + pu_call char(11) not null, + pu_zip char(6) not null, + primary key (pu_id) +); + +alter table Books add constraint FK_publication foreign key (pu_id) + references publishinghouse (pu_id) on delete restrict on update restrict; + +alter table Borrowing2 add constraint FK_Borrowing foreign key (bo_id) + references Books (bo_id) on delete restrict on update restrict; + +alter table Borrowing2 add constraint FK_Borrowing2 foreign key (borr_id) + references Borrowing (borr_id) on delete restrict on update restrict; + + +``` +