From aaa28c4a9bfa5a2d41d91ff97585031167ddd737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E6=AD=A3=E6=B3=A2?= <1938448998@qq.com> Date: Sun, 10 Sep 2023 20:03:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B9=9D=E6=9C=88=E5=85=AB=E5=8F=B7?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...56\345\272\223\351\253\230\347\272\247.md" | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 "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" 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 0000000..f858ae9 --- /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; + + +``` + -- Gitee From dc4b10f59afc666e97fcfcef37f945cc7f5b8f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E6=AD=A3=E6=B3=A2?= <1938448998@qq.com> Date: Sun, 10 Sep 2023 21:19:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B9=9D=E6=9C=88=E5=85=AB=E5=8F=B7?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...56\345\272\223\351\253\230\347\272\247.md" | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) 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" index f858ae9..e972e71 100644 --- "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" @@ -19,7 +19,8 @@ /* DBMS name: MySQL 5.0 */ /* Created on: 2023/9/10 19:49:40 */ /*==============================================================*/ - +create database tsglxt charset utf8; +use tsglxt; drop table if exists Books; @@ -32,7 +33,19 @@ drop table if exists publishinghouse; /*==============================================================*/ /* Table: Books */ /*==============================================================*/ -create table Books +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) +); +insert into publishinghouse values +(1001,'人民出版社','666666'), +(1002,'清华出版社','777777'), +(1003,'代哥出版社','888888'); + +create table Books ##图书 ( bo_id varchar(20) not null, pu_id varchar(10) not null, @@ -40,16 +53,24 @@ create table Books bo_loc varchar(20) not null, primary key (bo_id) ); +insert into Books values +(01,1001,'简爱','五楼二号柜第一排'), +(02,1002,'三国演义','四楼二号柜第二排'), +(03,1003,'神墓','三楼三号柜第一排'); /*==============================================================*/ /* Table: Borrowing */ /*==============================================================*/ -create table Borrowing +create table Borrowing ##借阅者 ( borr_id varchar(2) not null, - borr_name varchar(5) not null, + borr_name varchar(6) not null, primary key (borr_id) ); +insert into Borrowing values +(01,'代总'), +(02,'代副总'), +(03,'小代总'); /*==============================================================*/ /* Table: Borrowing2 */ @@ -62,17 +83,14 @@ create table Borrowing2 "Return" varchar(10) not null, primary key (bo_id, borr_id, borr_date) ); - +insert into Borrowing2 values +(01,01,'2023.2.1','2023.2.3'), +(02,02,'2023.7.1','2023.7.3'), +(03,03,'2023.6.1','2023.6.3'); /*==============================================================*/ /* 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; -- Gitee