From 56a842b7a00bc9fef88643993acf449e4965e1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E5=98=89=E4=B9=90?= <3196825236@qq.com> Date: Mon, 11 Sep 2023 11:47:34 +0000 Subject: [PATCH] =?UTF-8?q?13=20=E8=94=A1=E5=98=89=E4=B9=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡嘉乐 <3196825236@qq.com> --- ...24\350\256\260\344\275\234\344\270\232.md" | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 "13 \350\224\241\345\230\211\344\271\220/20230908\347\254\224\350\256\260\344\275\234\344\270\232.md" diff --git "a/13 \350\224\241\345\230\211\344\271\220/20230908\347\254\224\350\256\260\344\275\234\344\270\232.md" "b/13 \350\224\241\345\230\211\344\271\220/20230908\347\254\224\350\256\260\344\275\234\344\270\232.md" new file mode 100644 index 0000000..37f55b0 --- /dev/null +++ "b/13 \350\224\241\345\230\211\344\271\220/20230908\347\254\224\350\256\260\344\275\234\344\270\232.md" @@ -0,0 +1,101 @@ +### 数据库高级 + +## 笔记 + +## 操作步骤 + +1.创建概念模型(E-R图) CDM + +2.转换成逻辑模型 LDM + +3.转换成物理模型 PDM + +4.生成DDL + +### 作业 + +```mysql +CREATE DATABASE test22 charset utf8; +use test22; + + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/11 10:13:52 */ +/*==============================================================*/ + + +drop table if exists bookrent; + +drop table if exists bookreturn; + +drop table if exists bookse; + +drop table if exists uesr; + +/*==============================================================*/ +/* Table: bookrent */ +/*==============================================================*/ +create table bookrent +( + rent_id numeric(10,0) not null, + book_id int, + rent_date date not null, + book_odate date not null, + primary key (rent_id) +); + +/*==============================================================*/ +/* Table: bookreturn */ +/*==============================================================*/ +create table bookreturn +( + re_id numeric(10,0) not null, + book_id int, + re_date date not null, + primary key (re_id) +); + +/*==============================================================*/ +/* Table: "bookse-+" */ +/*==============================================================*/ +create table bookse +( + book_id int not null auto_increment, + user_id numeric(10,0) not null, + book_name char(5) not null, + book_bname char(10) not null, + book_number numeric(30,0) not null, + floor numeric(10,0) not null, + price int not null, + book_bid char(65) not null, + primary key (book_id) +); + +/*==============================================================*/ +/* Table: uesr */ +/*==============================================================*/ +create table uesr +( + user_id numeric(10,0) not null, + re_id numeric(30,0), + user_name char(10) not null, + password numeric(10,0) not null, + primary key (user_id) +); + +alter table bookrent add constraint FK_Relationship_2 foreign key (book_id) + references bookse (book_id) on delete restrict on update restrict; + +alter table bookreturn add constraint FK_Relationship_5 foreign key (book_id) + references bookse (book_id) on delete restrict on update restrict; + +alter table bookse add constraint FK_rent foreign key (user_id) + references uesr (user_id) on delete restrict on update restrict; + +alter table uesr add constraint FK_Relationship_4 foreign key (re_id) + references bookreturn (re_id) on delete restrict on update restrict; +``` + + + -- Gitee