diff --git "a/10 \346\270\251\350\264\265\351\233\257/\345\233\276\344\271\246\351\246\206\351\207\214\347\263\273\347\273\237.md" "b/10 \346\270\251\350\264\265\351\233\257/\345\233\276\344\271\246\351\246\206\351\207\214\347\263\273\347\273\237.md" new file mode 100644 index 0000000000000000000000000000000000000000..a42501270bbfc35c514e4506b950d1fcd42c6338 --- /dev/null +++ "b/10 \346\270\251\350\264\265\351\233\257/\345\233\276\344\271\246\351\246\206\351\207\214\347\263\273\347\273\237.md" @@ -0,0 +1,96 @@ +# 笔记 + +## powerdesigner + +1:创建概念模型图(CDM)以用户角度 + +2:转换逻辑模型图(LDM)以计算机角度 + +3:转换物理模型图(PDM)以数据角度 + +4:生成DDL + +数据库范式在实际中不会完全按照范式,根据需求实际操作 + +## 作业:图书管理系统 + +```java +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/11 23:10:39 */ +/*==============================================================*/ + + +drop table if exists book_borrowing; + +drop table if exists book_retrieval; + +drop table if exists return_books; + +drop table if exists user; + +/*==============================================================*/ +/* Table: book_borrowing */ +/*==============================================================*/ +create table book_borrowing +( + bb_id int not null auto_increment, + b_id int not null, + borrow_date date not null, + expiry_date date not null, + primary key (bb_id) +); + +/*==============================================================*/ +/* Table: book_retrieval */ +/*==============================================================*/ +create table book_retrieval +( + b_id int not null auto_increment, + u_id int not null, + b_name char(20) not null, + author char(20) not null, + quantity int not null, + floor char(5) not null, + price numeric(110,2), + shelf_number int, + primary key (b_id) +); + +/*==============================================================*/ +/* Table: return_books */ +/*==============================================================*/ +create table return_books +( + rb_id int not null auto_increment, + u_id int not null, + b_id int not null, + return_book date, + primary key (rb_id) +); + +/*==============================================================*/ +/* Table: user */ +/*==============================================================*/ +create table user +( + u_id int not null auto_increment, + u_name char(10) not null, + u_password char(10) not null, + primary key (u_id) +); + +alter table book_borrowing add constraint FK_borrow foreign key (b_id) + references book_retrieval (b_id) on delete restrict on update restrict; + +alter table book_retrieval add constraint FK_check foreign key (u_id) + references user (u_id) on delete restrict on update restrict; + +alter table return_books add constraint FK_return foreign key (u_id) + references user (u_id) on delete restrict on update restrict; + +alter table return_books add constraint FK_return_books foreign key (b_id) + references book_retrieval (b_id) on delete restrict on update restrict; + + +```