From 73d14ff785216a04d846df333394d4b8f1b80656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E5=AD=A6=E6=96=B0?= <2781716479@qq.com> Date: Sun, 10 Sep 2023 22:38:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B2=E5=AD=A6=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230909.md" | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 "47 \345\217\262\345\255\246\346\226\260/20230909.md" diff --git "a/47 \345\217\262\345\255\246\346\226\260/20230909.md" "b/47 \345\217\262\345\255\246\346\226\260/20230909.md" new file mode 100644 index 0000000..0c79993 --- /dev/null +++ "b/47 \345\217\262\345\255\246\346\226\260/20230909.md" @@ -0,0 +1,202 @@ +## 笔记: + +软件PowerDesigner的简单使用 + +制作CDM,LDM,PDM,生产DDL + +认识 CDM 概念模型( Conceptual Data Model ) + +LDM 逻辑模型(Logic Date Model ) + +PDM 物理模型 (Physical Date Model ) + +实体:画矩形,写里面的实体的名称 + +属性:椭圆或圆形,里面写属性名称,用线条与实体相连,如果是主属性名称下加下划线 + +关系:用线条将两个实体相连,中间可以用菱形表示中间的关系 + + + +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/9 13:52:45 */ +/*==============================================================*/ + + +CREATE DATABASE Book CHARSET utf8; +use Book; +drop table if exists book; + +drop table if exists borrow; + +drop table if exists giveBack; + +drop table if exists store; + +drop table if exists system; + +drop table if exists type; + +drop table if exists user; + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + b_id varchar(4) not null, + type_id int, + b_name varchar(8) not null, + b_writer varchar(8) not null, + b_press varchar(8) not null, + b_date varchar(12) not null, + b_price decimal(5,2) not null, + primary key (b_id) +); +INSERT INTO book VALUES +('001',1,'红楼梦','曹雪芹','人民文学出版社','2008年7月1日',51.5), +('002',2,'格林童话','格林兄弟','吉林美术出版社','2019年4月',38.9), +('003',3,'法医秦明','秦明','江苏文艺出版社','2020年10月',49.8); + + + +/*==============================================================*/ +/* Table: borrow */ +/*==============================================================*/ +create table borrow +( + borrow_id int not null auto_increment, + u_id int, + b_id varchar(4), + borrow_amout int not null, + borrow_date date not null, + borrow_time varchar(8) not null, + borrow_end date not null, + primary key (borrow_id) +); +INSERT INTO borrow VALUES +(1,1,'001',1,'2023-9-1','20天','2023-9-21'), +(2,3,'002',2,'2023-9-2','15天','2023-9-17'), +(3,2,'003',3,'2023-9-3','25天','2023-9-28'); + +/*==============================================================*/ +/* Table: giveBack */ +/*==============================================================*/ +create table giveBack +( + giveBack_id int not null auto_increment, + u_id int, + b_id varchar(4), + giveBack_amount int not null, + giveBack_date date not null, + primary key (giveBack_id) +); +INSERT into giveBack VALUES +(1,2,'001',1,'2023-9-20'), +(2,1,'003',3,'2023-9-25'), +(3,3,'002',4,'2023-9-30'); + +/*==============================================================*/ +/* Table: store */ +/*==============================================================*/ +create table store +( + s_id int not null auto_increment, + b_id varchar(4), + s_floor int not null, + s_area varchar(4) not null, + s_pressmark varchar(4) not null, + s_tier int not null, + primary key (s_id) +); +INSERT INTO store VALUES +(null,'001',3,'1区','01',2), +(null,'003',4,'2区','02',3), +(null,'002',5,'3区','03',4); + + +/*==============================================================*/ +/* Table: system */ +/*==============================================================*/ +create table system +( + system_id int not null auto_increment, + u_id int, + system_name varchar(12) not null, + system_amount int not null, + system_time varchar(8) not null, + system_price decimal not null, + primary key (system_id) +); +INSERT INTO system VALUES +(1,3,'普通会员',20,'1个月',30), +(2,1,'vip会员',35,'2个月',55), +(3,2,'svip会员',20,'3个月',75); + + + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + type_id int not null, + b_id varchar(4), + type_name varchar(8) not null, + primary key (type_id) +); +insert into type VALUES +(1,'001','文学类'), +(2,'002','少儿类'), +(3,'003','悬疑类'); + + +/*==============================================================*/ +/* Table: user */ +/*==============================================================*/ +create table user +( + u_id int not null auto_increment, + u_name varchar(4) not null, + u_sex varchar(4) not null, + u_age int not null, + u_tel varchar(12) not null, + primary key (u_id) +); +INSERT into user VALUES +(1,'张三','男',18,'15107465789'), +(2,'李四','女',19,'18234567891'), +(3,'王五','男',18,'13342849002'); + + + +alter table book add constraint FK_Relationship_4 foreign key (type_id) + references type (type_id) on delete restrict on update restrict; + +alter table borrow add constraint FK_ި˩ foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + +alter table borrow add constraint FK_ި˩ԃۧ foreign key (u_id) + references user (u_id) on delete restrict on update restrict; + +alter table giveBack add constraint FK_Relationship_3 foreign key (u_id) + references user (u_id) on delete restrict on update restrict; + +alter table giveBack add constraint FK_۹˩ foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + +alter table store add constraint FK_Relationship_1 foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + +alter table system add constraint FK_Relationship_5 foreign key (u_id) + references user (u_id) on delete restrict on update restrict; + +alter table type add constraint FK_Relationship_2 foreign key (b_id) + references book (b_id) on delete restrict on update restrict; +select * from user; +select * from borrow; +select * from user,borrow where user.u_id = borrow.u_id; +``` + -- Gitee