From dcc72d3a53582c172b4ebeddd2ece3ec04d4b2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BF=8A=E5=85=B4?= <3250103239@qq.com> Date: Mon, 11 Sep 2023 09:46:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...46\344\271\240\347\233\256\346\240\207.md" | 0 ...50\212\202\350\257\276 E-R\345\233\276.md" | 0 ...56\345\272\223\350\214\203\345\274\217.md" | 10 ++ ...41\347\220\206\347\263\273\347\273\237.md" | 122 ++++++++++++++++++ 4 files changed, 132 insertions(+) rename "14 \346\235\216\344\277\212\345\205\264/20230906 \345\244\247\344\272\214\345\255\246\344\271\240\347\233\256\346\240\207.md" => "14 \346\235\216\344\277\212\345\205\264/20230905 \345\244\247\344\272\214\345\255\246\344\271\240\347\233\256\346\240\207.md" (100%) rename "14 \346\235\216\344\277\212\345\205\264/20230907 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\347\254\254\344\270\200\350\212\202\350\257\276 E-R\345\233\276.md" => "14 \346\235\216\344\277\212\345\205\264/20230906 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\347\254\254\344\270\200\350\212\202\350\257\276 E-R\345\233\276.md" (100%) create mode 100644 "14 \346\235\216\344\277\212\345\205\264/20230907 \346\225\260\346\215\256\345\272\223\350\214\203\345\274\217.md" create mode 100644 "14 \346\235\216\344\277\212\345\205\264/20230908 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" diff --git "a/14 \346\235\216\344\277\212\345\205\264/20230906 \345\244\247\344\272\214\345\255\246\344\271\240\347\233\256\346\240\207.md" "b/14 \346\235\216\344\277\212\345\205\264/20230905 \345\244\247\344\272\214\345\255\246\344\271\240\347\233\256\346\240\207.md" similarity index 100% rename from "14 \346\235\216\344\277\212\345\205\264/20230906 \345\244\247\344\272\214\345\255\246\344\271\240\347\233\256\346\240\207.md" rename to "14 \346\235\216\344\277\212\345\205\264/20230905 \345\244\247\344\272\214\345\255\246\344\271\240\347\233\256\346\240\207.md" diff --git "a/14 \346\235\216\344\277\212\345\205\264/20230907 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\347\254\254\344\270\200\350\212\202\350\257\276 E-R\345\233\276.md" "b/14 \346\235\216\344\277\212\345\205\264/20230906 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\347\254\254\344\270\200\350\212\202\350\257\276 E-R\345\233\276.md" similarity index 100% rename from "14 \346\235\216\344\277\212\345\205\264/20230907 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\347\254\254\344\270\200\350\212\202\350\257\276 E-R\345\233\276.md" rename to "14 \346\235\216\344\277\212\345\205\264/20230906 \346\225\260\346\215\256\345\272\223\351\253\230\347\272\247\347\254\254\344\270\200\350\212\202\350\257\276 E-R\345\233\276.md" diff --git "a/14 \346\235\216\344\277\212\345\205\264/20230907 \346\225\260\346\215\256\345\272\223\350\214\203\345\274\217.md" "b/14 \346\235\216\344\277\212\345\205\264/20230907 \346\225\260\346\215\256\345\272\223\350\214\203\345\274\217.md" new file mode 100644 index 0000000..b27ee4a --- /dev/null +++ "b/14 \346\235\216\344\277\212\345\205\264/20230907 \346\225\260\346\215\256\345\272\223\350\214\203\345\274\217.md" @@ -0,0 +1,10 @@ +### 数据库范式 + + 范式也是一种规则 + +1. 要求字段内容,不可再分割,为了保证数字原子性 +2. 在满足范式1 的要求基础上,要求非主键字段要完全依赖主键(非主键要依赖整个联合主键)而不能只依赖部分 +3. 满足范式2 的基础上,非关键属性要直接依赖于主键不能出现传递依赖。 + +但是实际开发当中不会完全按照范式来设计,因为需求不同,所以有时会故意反范式 + diff --git "a/14 \346\235\216\344\277\212\345\205\264/20230908 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" "b/14 \346\235\216\344\277\212\345\205\264/20230908 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" new file mode 100644 index 0000000..47ef49a --- /dev/null +++ "b/14 \346\235\216\344\277\212\345\205\264/20230908 \345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.md" @@ -0,0 +1,122 @@ +### 结构 + +结构图分为: + +1. E-R图 +2. powerDesigner + +powerDesigner使用 + +1. 创建概念模型 类似于E-R图 以人的角度 +2. 转成逻辑模型 以计算机的角度 +3. 转换成物理模型 以数据库的角度 +4. 生成DDL语句 + +### 图书管理系统代码 + +~~~mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/11 9:34:50 */ +/*==============================================================*/ +CREATE DATABASE take CHARSET utf8; +use take; +drop table if exists Admin; + +drop table if exists Borrowinfo; + +drop table if exists Readerinfo; + +drop table if exists book; + +drop table if exists limits; + +/*==============================================================*/ +/* Table: Admin */ +/*==============================================================*/ +create table Admin +( + A_id char(5) not null, + book_id char(10) not null, + Boor_id int not null, + A_name char(15) not null, + A_paw char(16), + A_tel char(11) not null, + primary key (A_id) +); + +/*==============================================================*/ +/* Table: Borrowinfo */ +/*==============================================================*/ +create table Borrowinfo +( + Boor_id int not null, + Reade_id char(10) not null, + book_id char(10) not null, + Rea_id char(10) not null, + Book_number char(10) not null, + Boor_time datetime not null, + due_time datetime not null, + return_time datetime not null, + state int not null, + admin_id char(10) not null, + primary key (Boor_id) +); + +/*==============================================================*/ +/* Table: Readerinfo */ +/*==============================================================*/ +create table Readerinfo +( + Reade_id char(10) not null, + Level char(10) not null, + name char(15) not null, + Reade_faculty char(10) not null, + Readejjtime timestamp not null, + primary key (Reade_id) +); + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + book_id char(10) not null, + title char(25) not null, + quantity int not null, + address varchar(25) not null, + author char(30) not null, + press char(30) not null, + time timestamp not null, + primary key (book_id) +); + +/*==============================================================*/ +/* Table: limits */ +/*==============================================================*/ +create table limits +( + Level char(10) not null, + MaxBookNum char(10) not null, + MaxDays char(10) not null, + primary key (Level) +); + +alter table Admin add constraint FK_admin foreign key (book_id) + references book (book_id) on delete restrict on update restrict; + +alter table Admin add constraint FK_regulate foreign key (Boor_id) + references Borrowinfo (Boor_id) on delete restrict on update restrict; + +alter table Borrowinfo add constraint FK_Borrowinfo foreign key (Reade_id) + references Readerinfo (Reade_id) on delete restrict on update restrict; + +alter table Borrowinfo add constraint FK_borrow foreign key (book_id) + references book (book_id) on delete restrict on update restrict; + +alter table Readerinfo add constraint FK_astrict foreign key (Level) + references limits (Level) on delete restrict on update restrict; + + +~~~ + -- Gitee