diff --git "a/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/2.sql" "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/2.sql" new file mode 100644 index 0000000000000000000000000000000000000000..d004cd2d52388d6189d5e9abbe79e24d33170f1f --- /dev/null +++ "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/2.sql" @@ -0,0 +1,79 @@ +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2024/9/4 21:49:22 */ +/*==============================================================*/ + + +drop table if exists actor; + +drop table if exists canyan; + +drop table if exists director; + +drop table if exists movie; + +drop table if exists pinfen; + +/*==============================================================*/ +/* Table: actor */ +/*==============================================================*/ +create table actor +( + aid int not null, + aname varchar(255), + primary key (aid) +); + +/*==============================================================*/ +/* Table: canyan */ +/*==============================================================*/ +create table canyan +( + aid int not null, + did int not null, + primary key (aid, did) +); + +/*==============================================================*/ +/* Table: director */ +/*==============================================================*/ +create table director +( + did int not null, + dname varchar(255), + primary key (did) +); + +/*==============================================================*/ +/* Table: movie */ +/*==============================================================*/ +create table movie +( + mid int not null, + number float(3) not null, + did int not null, + mname varchar(255), + primary key (mid) +); + +/*==============================================================*/ +/* Table: pinfen */ +/*==============================================================*/ +create table pinfen +( + number float(3) not null, + primary key (number) +); + +alter table canyan add constraint FK_canyan foreign key (aid) + references actor (aid) on delete restrict on update restrict; + +alter table canyan add constraint FK_canyan2 foreign key (did) + references director (did) on delete restrict on update restrict; + +alter table movie add constraint FK_guanlian foreign key (number) + references pinfen (number) on delete restrict on update restrict; + +alter table movie add constraint FK_zhidao foreign key (did) + references director (did) on delete restrict on update restrict; + diff --git "a/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/Snipaste_2024-09-04_21-44-45.png" "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/Snipaste_2024-09-04_21-44-45.png" new file mode 100644 index 0000000000000000000000000000000000000000..f3b754f5d521b321c2cc9da54fc1ba9c73500f3c Binary files /dev/null and "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/Snipaste_2024-09-04_21-44-45.png" differ diff --git "a/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/Snipaste_2024-09-04_21-47-12.png" "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/Snipaste_2024-09-04_21-47-12.png" new file mode 100644 index 0000000000000000000000000000000000000000..9bdffce480ce3aa0810302ae5781b55c4e2e0bac Binary files /dev/null and "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/Snipaste_2024-09-04_21-47-12.png" differ diff --git "a/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/Snipaste_2024-09-04_21-47-50.png" "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/Snipaste_2024-09-04_21-47-50.png" new file mode 100644 index 0000000000000000000000000000000000000000..7d943b8916ff86124185548adf00a621a6c6c1a3 Binary files /dev/null and "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/Snipaste_2024-09-04_21-47-50.png" differ diff --git "a/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/\347\254\224\350\256\260.md" "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..8e3d902a2cbb12ec495efe2e5f748709daba1621 --- /dev/null +++ "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/\347\254\224\350\256\260.md" @@ -0,0 +1,26 @@ + # 1.表之间表关系 + + ## 1.一对一:A表之中的数据,在B表中只能找到一条数据关 联,反之亦然。 + + ## 2.一对多:A表中的数据,在B表能找到多条数据关联。 + +## 3.多对多:A表中的数据,在B表能找到多条数据关联。反之亦然。 + +## 2.数据库设计三大范式 + +## 1. 第一范式:确保每个表格中的字段都包含原子值,即每个字段只能存储一个单一的值,不允许出现重复的组。 + +## 2.第二范式:确保每个非主属性完全依赖于主键,而不是主键的一部分。解决了部分依赖的问题。 + +## 3.第三范式:确保每个非主属性既不依赖于主键的部分,也不依赖于其他非主属性(消除传递依赖)。 + + + + + + + + + + + diff --git "a/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/\347\256\200\345\215\225\347\232\204\344\270\232\345\212\241\346\237\245\350\257\242\350\257\255\345\217\245.md" "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/\347\256\200\345\215\225\347\232\204\344\270\232\345\212\241\346\237\245\350\257\242\350\257\255\345\217\245.md" new file mode 100644 index 0000000000000000000000000000000000000000..584a917c2cffdda649467dd626ab17cd7f82cc84 --- /dev/null +++ "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/\347\256\200\345\215\225\347\232\204\344\270\232\345\212\241\346\237\245\350\257\242\350\257\255\345\217\245.md" @@ -0,0 +1,9 @@ +select *from actor. + +select *from canyan. + +select *from director. + +select *from movie. + +select *from pinfen. \ No newline at end of file diff --git "a/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/\351\234\200\346\261\202\345\210\206\346\236\220.md" "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/\351\234\200\346\261\202\345\210\206\346\236\220.md" new file mode 100644 index 0000000000000000000000000000000000000000..8832e19dc1a23873587059b504d39ee2a7a26dda --- /dev/null +++ "b/\351\231\210\346\231\223\344\270\234/20240904 \346\225\260\346\215\256\345\272\223\350\256\276\350\256\241/\351\234\200\346\261\202\345\210\206\346\236\220.md" @@ -0,0 +1,8 @@ +# 每部电影有一个详细的评分记录,但评分记录只属于一部电影。 + +# 一个导演执导多部电影,但每部电影只有一个导演。 + +# 电影和演员之间的关系。一部电影可以有多名演员,而一名演员可以出演多部电影。 + + +