From d4a64296a4c2ca64b5a9148cbed950e9184c10fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B0=B8=E6=B7=B3?= <2678158018@qq.com> Date: Thu, 7 Sep 2023 22:17:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230609\344\275\234\344\270\232.md" | 94 ------------------- .../20230906\347\254\224\350\256\260.md" | 0 .../20230907\344\275\234\344\270\232.md" | 71 ++++++++++++++ .../20230907\347\254\224\350\256\260.md" | 15 +++ 4 files changed, 86 insertions(+), 94 deletions(-) delete mode 100644 "18 \345\276\220\346\260\270\346\267\263/20230609\344\275\234\344\270\232.md" rename "18 \345\276\220\346\260\270\346\267\263/20230609\347\254\224\350\256\260.md" => "18 \345\276\220\346\260\270\346\267\263/20230906\347\254\224\350\256\260.md" (100%) create mode 100644 "18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" create mode 100644 "18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230609\344\275\234\344\270\232.md" "b/18 \345\276\220\346\260\270\346\267\263/20230609\344\275\234\344\270\232.md" deleted file mode 100644 index 0b74def..0000000 --- "a/18 \345\276\220\346\260\270\346\267\263/20230609\344\275\234\344\270\232.md" +++ /dev/null @@ -1,94 +0,0 @@ - - -```sql -CREATE DATABASE school CHARSET utf8; -use school; --- 院系表 - CREATE TABLE faculty( - d_id INT PRIMARY KEY, - d_name VARCHAR(255) - ); - INSERT INTO faculty VALUES - (1,'软件工程学院'); - -- 专业表 - CREATE TABLE specialty( - S_id int PRIMARY KEY, - S_name VARCHAR(255), - d_id int, - FOREIGN KEY (d_id) REFERENCES faculty(d_id) - ); - INSERT INTO specialty VALUES - (1,'软件技术',1); - -- 班级表 - CREATE TABLE class( - C_id INT PRIMARY KEY, - C_name VARCHAR(20), - grade VARCHAR(5), - s_id INT, - FOREIGN KEY (s_id) REFERENCES specialty(s_id) - ); - INSERT INTO class VALUES - (1,'软件技术1班','22级',1), - (2,'软件技术2班','22级',1), - (3,'软件技术7班','22级',1), - (4,'软件技术9班','22级',1); - -- 课程 - CREATE TABLE course( - couseId int PRIMARY key, - courseName varchar(10), - c_id int, - r_id int, - foreign key (c_id) references class(C_id), - foreign key (r_id) references classroom(r_id) - ); - insert into course VALUES - (1,'Java',1,1), - (2,'MySQL',2,2); - -- 教室 - create table classroom( - r_id int PRIMARY KEY, - r_name varchar(10) - ); - insert into classroom values - (1,'实训一'), - (2,'实训二'); - -- 课程表 - create table `select` ( - selectId int primary key, - couseId int, - time varchar(20), - t_id int, - r_id int, - foreign key (couseId) references course(couseId), - foreign key (t_id) references teacher(t_id), - foreign key (r_id) references classroom(r_id) - ); - insert into `select` values - (1,1,'周一8:00-11:40',2,1), - (2,2,'周一14:00-17:40',1,2); - -- 教师 - create table teacher( - t_id int primary key, - t_name varchar(10), - couseId int, - foreign key (couseId) references course(couseId) - ); - insert into teacher values - (1,'丘丘',1), - (2,'黑马pink',2); - -- 学生 -CREATE TABLE student ( - stu_name VARCHAR(25), - stu_id INT PRIMARY KEY, - C_id INT, - select_id INT, - foreign key (C_id) references class(C_id), - FOREIGN KEY (select_id) REFERENCES `select`(selectId) - ); - INSERT INTO student VALUES - ('一',17,1,1), - ('二',52,2,2), - ('三',49,3,1), - ('四',22,4,1); -``` - diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230609\347\254\224\350\256\260.md" "b/18 \345\276\220\346\260\270\346\267\263/20230906\347\254\224\350\256\260.md" similarity index 100% rename from "18 \345\276\220\346\260\270\346\267\263/20230609\347\254\224\350\256\260.md" rename to "18 \345\276\220\346\260\270\346\267\263/20230906\347\254\224\350\256\260.md" diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" "b/18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" new file mode 100644 index 0000000..0246a30 --- /dev/null +++ "b/18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" @@ -0,0 +1,71 @@ + + +```sql +create database school charset utf8; +use school; +-- 学院表 +create table deparment( +d_id int primary key auto_increment, +d_name varchar(50) +); +-- 专业表 +create table major( +m_id int primary key, +m_name varchar(50), +foreign key (m_id) references deparment(d_id) +); +-- 班级表 +create table class( +cl_id int primary key, +cl_name varchar(50), +foreign key (cl_id) references major(m_id) +); +-- 学生表 +create table student( +stu_id int primary key, +stu_name varchar(50), +stu_sex enum('男','女'), +stu_age int, +foreign key (stu_id) references class(cl_id) +); +-- 课程信息表 +create table course( +cou_id int primary key, +cou_name varchar(50), +foreign key (cou_id) references student(stu_id) +); +-- 成绩表 +create table score( +sc_id int, +sc_performance double(3,1), +stu_id int, +cou_id int, +foreign key (stu_id) references student(stu_id), +foreign key (cou_id) references course(cou_id) +); + +-- 老师表 +create table teacher( +t_id int primary key, +t_name varchar(50), +t_sex enum('男','女'), +t_age int +); +-- 教室表 +create table classroom( +cr_id int primary key, +cr_name varchar(50) +); +-- 课程表 +create table timetable( +otto_section int, +otto_week varchar(50), +stu_id int, +t_id int, +cr_id int, +foreign key (stu_id) references student(stu_id), +foreign key (t_id) references teacher(t_id), +foreign key (cr_id) references classroom(cr_id) +); +``` + diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" "b/18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" new file mode 100644 index 0000000..9916349 --- /dev/null +++ "b/18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" @@ -0,0 +1,15 @@ +设计关系数据库时,遵从不同的规范要求,设计出合理的[关系型数据库](https://baike.baidu.com/item/关系型数据库/8999831?fromModule=lemma_inlink),这些不同的[规范要求](https://baike.baidu.com/item/规范要求/55443795?fromModule=lemma_inlink)被称为不同的范式,各种范式呈递次规范,越高的范式数据库冗余越小。 + +第一范式 + +第一范式主要是确保数据表中每个字段的值必须具有`原子性`,也就是说数据表中每个字段的值为`不可再次拆分`的最小数据单元。 +我们在设计某个字段的时候,对于字段X来说,不能把字段X拆分成字段X-1和字段X-2。事实上都会满足第一范式的要求,不会将字段进行拆分。 + +第二范式 + +第一范式主要是确保数据表中每个字段的值必须具有`原子性`,也就是说数据表中每个字段的值为`不可再次拆分`的最小数据单元。 +我们在设计某个字段的时候,对于字段X来说,不能把字段X拆分成字段X-1和字段X-2。事实上都会满足第一范式的要求,不会将字段进行拆分。 + +第三范式 + +第三范式是在第二范式的基础上,确保数据表中的每一个非主键字段都和主键字段直接相关,也就是说,要求数据表中的所有非主键字段不能依赖于其他非主键字段。(即,不能存在非主属性A依赖于非主属性B,非主属性B依赖于主键c的情况,即存在"A→B→C""的决定关系)通俗地讲,该规则的意思是所有非主键属性之间不能有依赖关系,必须相互独立。 -- Gitee From 9de614719ce971da1c3d26ec0a2e52049e200857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B0=B8=E6=B7=B3?= <2678158018@qq.com> Date: Thu, 7 Sep 2023 22:18:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E7=AC=94?= =?UTF-8?q?=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230907\344\275\234\344\270\232.md" | 71 ------------------- .../20230907\347\254\224\350\256\260.md" | 15 ---- 2 files changed, 86 deletions(-) delete mode 100644 "18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" delete mode 100644 "18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" "b/18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" deleted file mode 100644 index 0246a30..0000000 --- "a/18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" +++ /dev/null @@ -1,71 +0,0 @@ - - -```sql -create database school charset utf8; -use school; --- 学院表 -create table deparment( -d_id int primary key auto_increment, -d_name varchar(50) -); --- 专业表 -create table major( -m_id int primary key, -m_name varchar(50), -foreign key (m_id) references deparment(d_id) -); --- 班级表 -create table class( -cl_id int primary key, -cl_name varchar(50), -foreign key (cl_id) references major(m_id) -); --- 学生表 -create table student( -stu_id int primary key, -stu_name varchar(50), -stu_sex enum('男','女'), -stu_age int, -foreign key (stu_id) references class(cl_id) -); --- 课程信息表 -create table course( -cou_id int primary key, -cou_name varchar(50), -foreign key (cou_id) references student(stu_id) -); --- 成绩表 -create table score( -sc_id int, -sc_performance double(3,1), -stu_id int, -cou_id int, -foreign key (stu_id) references student(stu_id), -foreign key (cou_id) references course(cou_id) -); - --- 老师表 -create table teacher( -t_id int primary key, -t_name varchar(50), -t_sex enum('男','女'), -t_age int -); --- 教室表 -create table classroom( -cr_id int primary key, -cr_name varchar(50) -); --- 课程表 -create table timetable( -otto_section int, -otto_week varchar(50), -stu_id int, -t_id int, -cr_id int, -foreign key (stu_id) references student(stu_id), -foreign key (t_id) references teacher(t_id), -foreign key (cr_id) references classroom(cr_id) -); -``` - diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" "b/18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" deleted file mode 100644 index 9916349..0000000 --- "a/18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" +++ /dev/null @@ -1,15 +0,0 @@ -设计关系数据库时,遵从不同的规范要求,设计出合理的[关系型数据库](https://baike.baidu.com/item/关系型数据库/8999831?fromModule=lemma_inlink),这些不同的[规范要求](https://baike.baidu.com/item/规范要求/55443795?fromModule=lemma_inlink)被称为不同的范式,各种范式呈递次规范,越高的范式数据库冗余越小。 - -第一范式 - -第一范式主要是确保数据表中每个字段的值必须具有`原子性`,也就是说数据表中每个字段的值为`不可再次拆分`的最小数据单元。 -我们在设计某个字段的时候,对于字段X来说,不能把字段X拆分成字段X-1和字段X-2。事实上都会满足第一范式的要求,不会将字段进行拆分。 - -第二范式 - -第一范式主要是确保数据表中每个字段的值必须具有`原子性`,也就是说数据表中每个字段的值为`不可再次拆分`的最小数据单元。 -我们在设计某个字段的时候,对于字段X来说,不能把字段X拆分成字段X-1和字段X-2。事实上都会满足第一范式的要求,不会将字段进行拆分。 - -第三范式 - -第三范式是在第二范式的基础上,确保数据表中的每一个非主键字段都和主键字段直接相关,也就是说,要求数据表中的所有非主键字段不能依赖于其他非主键字段。(即,不能存在非主属性A依赖于非主属性B,非主属性B依赖于主键c的情况,即存在"A→B→C""的决定关系)通俗地讲,该规则的意思是所有非主键属性之间不能有依赖关系,必须相互独立。 -- Gitee From 1b7aa7d2187ec76864ae303b8e99edd0553fdf8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B0=B8=E6=B7=B3?= <2678158018@qq.com> Date: Thu, 7 Sep 2023 22:19:21 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230907\344\275\234\344\270\232.md" | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 "18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" "b/18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" new file mode 100644 index 0000000..0246a30 --- /dev/null +++ "b/18 \345\276\220\346\260\270\346\267\263/20230907\344\275\234\344\270\232.md" @@ -0,0 +1,71 @@ + + +```sql +create database school charset utf8; +use school; +-- 学院表 +create table deparment( +d_id int primary key auto_increment, +d_name varchar(50) +); +-- 专业表 +create table major( +m_id int primary key, +m_name varchar(50), +foreign key (m_id) references deparment(d_id) +); +-- 班级表 +create table class( +cl_id int primary key, +cl_name varchar(50), +foreign key (cl_id) references major(m_id) +); +-- 学生表 +create table student( +stu_id int primary key, +stu_name varchar(50), +stu_sex enum('男','女'), +stu_age int, +foreign key (stu_id) references class(cl_id) +); +-- 课程信息表 +create table course( +cou_id int primary key, +cou_name varchar(50), +foreign key (cou_id) references student(stu_id) +); +-- 成绩表 +create table score( +sc_id int, +sc_performance double(3,1), +stu_id int, +cou_id int, +foreign key (stu_id) references student(stu_id), +foreign key (cou_id) references course(cou_id) +); + +-- 老师表 +create table teacher( +t_id int primary key, +t_name varchar(50), +t_sex enum('男','女'), +t_age int +); +-- 教室表 +create table classroom( +cr_id int primary key, +cr_name varchar(50) +); +-- 课程表 +create table timetable( +otto_section int, +otto_week varchar(50), +stu_id int, +t_id int, +cr_id int, +foreign key (stu_id) references student(stu_id), +foreign key (t_id) references teacher(t_id), +foreign key (cr_id) references classroom(cr_id) +); +``` + -- Gitee From 21cf40bdcbf61ba713e7a9644ff0c49d3f0f599d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B0=B8=E6=B7=B3?= <2678158018@qq.com> Date: Thu, 7 Sep 2023 22:21:02 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=AC=A1=E7=AC=94?= =?UTF-8?q?=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230907\347\254\224\350\256\260.md" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" "b/18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" new file mode 100644 index 0000000..9916349 --- /dev/null +++ "b/18 \345\276\220\346\260\270\346\267\263/20230907\347\254\224\350\256\260.md" @@ -0,0 +1,15 @@ +设计关系数据库时,遵从不同的规范要求,设计出合理的[关系型数据库](https://baike.baidu.com/item/关系型数据库/8999831?fromModule=lemma_inlink),这些不同的[规范要求](https://baike.baidu.com/item/规范要求/55443795?fromModule=lemma_inlink)被称为不同的范式,各种范式呈递次规范,越高的范式数据库冗余越小。 + +第一范式 + +第一范式主要是确保数据表中每个字段的值必须具有`原子性`,也就是说数据表中每个字段的值为`不可再次拆分`的最小数据单元。 +我们在设计某个字段的时候,对于字段X来说,不能把字段X拆分成字段X-1和字段X-2。事实上都会满足第一范式的要求,不会将字段进行拆分。 + +第二范式 + +第一范式主要是确保数据表中每个字段的值必须具有`原子性`,也就是说数据表中每个字段的值为`不可再次拆分`的最小数据单元。 +我们在设计某个字段的时候,对于字段X来说,不能把字段X拆分成字段X-1和字段X-2。事实上都会满足第一范式的要求,不会将字段进行拆分。 + +第三范式 + +第三范式是在第二范式的基础上,确保数据表中的每一个非主键字段都和主键字段直接相关,也就是说,要求数据表中的所有非主键字段不能依赖于其他非主键字段。(即,不能存在非主属性A依赖于非主属性B,非主属性B依赖于主键c的情况,即存在"A→B→C""的决定关系)通俗地讲,该规则的意思是所有非主键属性之间不能有依赖关系,必须相互独立。 -- Gitee