From 2b44a3618577e126a71eead6402ad6e6196d417a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A2=A6=E6=A2=A6?= <3195337478@qq.com> Date: Tue, 12 Sep 2023 13:58:28 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E9=99=88=E6=A2=A6=E6=A2=A6=E7=9A=84?= =?UTF-8?q?=E7=AC=AC=E4=BA=94=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈梦梦 <3195337478@qq.com> --- .../20230912.md" | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 "01 \351\231\210\346\242\246\346\242\246/20230912.md" diff --git "a/01 \351\231\210\346\242\246\346\242\246/20230912.md" "b/01 \351\231\210\346\242\246\346\242\246/20230912.md" new file mode 100644 index 0000000..8b3bc23 --- /dev/null +++ "b/01 \351\231\210\346\242\246\346\242\246/20230912.md" @@ -0,0 +1,231 @@ +2023年09月12日 + +今天复习了一下图书管理系统,但是犯困还是没听见怎么写,然后老师布置了新作业,不知道是不是老师给了一点思路,感觉这个图很快就做出来了。至少不会像图书管理那个一样一塌糊涂,但是还有很多不会的。比如表格关联,数据如何插入,希望明天可以解决今天的问题,那个艺人的表格真的不会插!!!! + +### er图 + +![er](E:\高级数据库\04\er.png) + +~~~mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023-09-12 11:26:47 */ +/*==============================================================*/ +drop database if exists zy; +create database zy charset utf8; +use zy; + +drop table if exists artist; + +drop table if exists country; + +drop table if exists director; + +drop table if exists language; + +drop table if exists movie; + +drop table if exists protagonist; + +drop table if exists rating; + +drop table if exists review; + +drop table if exists scriptwriter; + +drop table if exists type; + +drop table if exists user; + +/*==============================================================*/ +/* Table: artist */ +/*==============================================================*/ +create table artist +( + art_id int not null, + movie_id int not null, + pro_id int not null, + dir_id int not null, + scr_id int not null, + art_name char(10) not null, + art_work char(10) not null, + primary key (art_id) +); + +/*==============================================================*/ +/* Table: country */ +/*==============================================================*/ +create table country +( + cou_id int not null, + movie_id int not null, + cou_name char(20) not null, + primary key (cou_id) +); + + +insert into country values +(1,1,"美国,韩国"); +/*==============================================================*/ +/* Table: director */ +/*==============================================================*/ +create table director +( + dir_id int not null, + dir_name char(10) not null, + primary key (dir_id) +); + +insert into director values +(1,'席琳·宋'); +/*==============================================================*/ +/* Table: language */ +/*==============================================================*/ +create table `language` +( + lang_id int not null, + movie_id int not null, + lang char(10) not null, + primary key (lang_id) +); +insert into `language` values +(1,1,'英语,韩语'); + +/*==============================================================*/ +/* Table: movie */ +/*==============================================================*/ +create table movie +( + movie_id int not null, + movie_name char(20) not null, + release_date date not null, + length int not null, + primary key (movie_id) +); +insert into movie values +(1,'过往人生','2023-01-21',160); + +/*==============================================================*/ +/* Table: protagonist */ +/*==============================================================*/ +create table protagonist +( + pro_id int not null, + pro_name char(10) not null, + primary key (pro_id) +); +insert into protagonist values +(1,' 格蕾塔·李'), +(2,' 刘台午'), +(3,' 约翰·马加罗'), +(4,'文胜雅'), +(5,'尹智慧 '); + +/*==============================================================*/ +/* Table: rating */ +/*==============================================================*/ +create table rating +( + movie_id int not null, + user_id int not null, + user_rating char(10) not null, + primary key (movie_id, user_id) +); + +insert into rating values +(1,1,'90分'); + +/*==============================================================*/ +/* Table: review */ +/*==============================================================*/ +create table review +( + re_id int not null, + user_id int not null, + movie_id int not null, + re_name char(20) not null, + re_text char(100) not null, + re_appraise int not null, + primary key (re_id) +); +insert into review values +(1,1,1,'男人总是留守过去,女人总是面向未来','在柏林的映后采访中,一个记者提了这样一个问题:为什么在这部电影里,男人总是承受、感性、饱含爱的那一方,而女人则冷静、选择活在当下、坚持走在自己的路上',5); + + +/*==============================================================*/ +/* Table: scriptwriter */ +/*==============================================================*/ +create table scriptwriter +( + scr_id int not null, + scr_name char(10) not null, + primary key (scr_id) +); +insert into scriptwriter values +(1,'席琳·宋'); + + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + type_id int not null, + movie_id int not null, + type_name char(10) not null, + primary key (type_id) +); +insert into type values +(1,1,'剧情 / 爱情'); + + +/*==============================================================*/ +/* Table: user */ +/*==============================================================*/ +create table `user` +( + user_id int not null, + user_name char(10) not null, + primary key (user_id) +); +insert into `user` values +(1,'陈梦梦'); + +alter table artist add constraint FK_Relationship_4 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table artist add constraint FK_Relationship_5 foreign key (pro_id) + references protagonist (pro_id) on delete restrict on update restrict; + +alter table artist add constraint FK_Relationship_6 foreign key (dir_id) + references director (dir_id) on delete restrict on update restrict; + +alter table artist add constraint FK_Relationship_7 foreign key (scr_id) + references scriptwriter (scr_id) on delete restrict on update restrict; + +alter table country add constraint FK_Relationship_3 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table language add constraint FK_Relationship_2 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table rating add constraint FK_Relationship_11 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table rating add constraint FK_Relationship_12 foreign key (user_id) + references user (user_id) on delete restrict on update restrict; + +alter table review add constraint FK_Relationship_10 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table review add constraint FK_Relationship_9 foreign key (user_id) + references user (user_id) on delete restrict on update restrict; + +alter table type add constraint FK_Relationship_1 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + + +~~~ + + + -- Gitee From 31c04c7d7ef32862e06d7dc120d2a30ee8cee6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A2=A6=E6=A2=A6?= <3195337478@qq.com> Date: Tue, 12 Sep 2023 14:54:56 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=2001?= =?UTF-8?q?=20=E9=99=88=E6=A2=A6=E6=A2=A6/20230912.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230912.md" | 231 ------------------ 1 file changed, 231 deletions(-) delete mode 100644 "01 \351\231\210\346\242\246\346\242\246/20230912.md" diff --git "a/01 \351\231\210\346\242\246\346\242\246/20230912.md" "b/01 \351\231\210\346\242\246\346\242\246/20230912.md" deleted file mode 100644 index 8b3bc23..0000000 --- "a/01 \351\231\210\346\242\246\346\242\246/20230912.md" +++ /dev/null @@ -1,231 +0,0 @@ -2023年09月12日 - -今天复习了一下图书管理系统,但是犯困还是没听见怎么写,然后老师布置了新作业,不知道是不是老师给了一点思路,感觉这个图很快就做出来了。至少不会像图书管理那个一样一塌糊涂,但是还有很多不会的。比如表格关联,数据如何插入,希望明天可以解决今天的问题,那个艺人的表格真的不会插!!!! - -### er图 - -![er](E:\高级数据库\04\er.png) - -~~~mysql -/*==============================================================*/ -/* DBMS name: MySQL 5.0 */ -/* Created on: 2023-09-12 11:26:47 */ -/*==============================================================*/ -drop database if exists zy; -create database zy charset utf8; -use zy; - -drop table if exists artist; - -drop table if exists country; - -drop table if exists director; - -drop table if exists language; - -drop table if exists movie; - -drop table if exists protagonist; - -drop table if exists rating; - -drop table if exists review; - -drop table if exists scriptwriter; - -drop table if exists type; - -drop table if exists user; - -/*==============================================================*/ -/* Table: artist */ -/*==============================================================*/ -create table artist -( - art_id int not null, - movie_id int not null, - pro_id int not null, - dir_id int not null, - scr_id int not null, - art_name char(10) not null, - art_work char(10) not null, - primary key (art_id) -); - -/*==============================================================*/ -/* Table: country */ -/*==============================================================*/ -create table country -( - cou_id int not null, - movie_id int not null, - cou_name char(20) not null, - primary key (cou_id) -); - - -insert into country values -(1,1,"美国,韩国"); -/*==============================================================*/ -/* Table: director */ -/*==============================================================*/ -create table director -( - dir_id int not null, - dir_name char(10) not null, - primary key (dir_id) -); - -insert into director values -(1,'席琳·宋'); -/*==============================================================*/ -/* Table: language */ -/*==============================================================*/ -create table `language` -( - lang_id int not null, - movie_id int not null, - lang char(10) not null, - primary key (lang_id) -); -insert into `language` values -(1,1,'英语,韩语'); - -/*==============================================================*/ -/* Table: movie */ -/*==============================================================*/ -create table movie -( - movie_id int not null, - movie_name char(20) not null, - release_date date not null, - length int not null, - primary key (movie_id) -); -insert into movie values -(1,'过往人生','2023-01-21',160); - -/*==============================================================*/ -/* Table: protagonist */ -/*==============================================================*/ -create table protagonist -( - pro_id int not null, - pro_name char(10) not null, - primary key (pro_id) -); -insert into protagonist values -(1,' 格蕾塔·李'), -(2,' 刘台午'), -(3,' 约翰·马加罗'), -(4,'文胜雅'), -(5,'尹智慧 '); - -/*==============================================================*/ -/* Table: rating */ -/*==============================================================*/ -create table rating -( - movie_id int not null, - user_id int not null, - user_rating char(10) not null, - primary key (movie_id, user_id) -); - -insert into rating values -(1,1,'90分'); - -/*==============================================================*/ -/* Table: review */ -/*==============================================================*/ -create table review -( - re_id int not null, - user_id int not null, - movie_id int not null, - re_name char(20) not null, - re_text char(100) not null, - re_appraise int not null, - primary key (re_id) -); -insert into review values -(1,1,1,'男人总是留守过去,女人总是面向未来','在柏林的映后采访中,一个记者提了这样一个问题:为什么在这部电影里,男人总是承受、感性、饱含爱的那一方,而女人则冷静、选择活在当下、坚持走在自己的路上',5); - - -/*==============================================================*/ -/* Table: scriptwriter */ -/*==============================================================*/ -create table scriptwriter -( - scr_id int not null, - scr_name char(10) not null, - primary key (scr_id) -); -insert into scriptwriter values -(1,'席琳·宋'); - - -/*==============================================================*/ -/* Table: type */ -/*==============================================================*/ -create table type -( - type_id int not null, - movie_id int not null, - type_name char(10) not null, - primary key (type_id) -); -insert into type values -(1,1,'剧情 / 爱情'); - - -/*==============================================================*/ -/* Table: user */ -/*==============================================================*/ -create table `user` -( - user_id int not null, - user_name char(10) not null, - primary key (user_id) -); -insert into `user` values -(1,'陈梦梦'); - -alter table artist add constraint FK_Relationship_4 foreign key (movie_id) - references movie (movie_id) on delete restrict on update restrict; - -alter table artist add constraint FK_Relationship_5 foreign key (pro_id) - references protagonist (pro_id) on delete restrict on update restrict; - -alter table artist add constraint FK_Relationship_6 foreign key (dir_id) - references director (dir_id) on delete restrict on update restrict; - -alter table artist add constraint FK_Relationship_7 foreign key (scr_id) - references scriptwriter (scr_id) on delete restrict on update restrict; - -alter table country add constraint FK_Relationship_3 foreign key (movie_id) - references movie (movie_id) on delete restrict on update restrict; - -alter table language add constraint FK_Relationship_2 foreign key (movie_id) - references movie (movie_id) on delete restrict on update restrict; - -alter table rating add constraint FK_Relationship_11 foreign key (movie_id) - references movie (movie_id) on delete restrict on update restrict; - -alter table rating add constraint FK_Relationship_12 foreign key (user_id) - references user (user_id) on delete restrict on update restrict; - -alter table review add constraint FK_Relationship_10 foreign key (movie_id) - references movie (movie_id) on delete restrict on update restrict; - -alter table review add constraint FK_Relationship_9 foreign key (user_id) - references user (user_id) on delete restrict on update restrict; - -alter table type add constraint FK_Relationship_1 foreign key (movie_id) - references movie (movie_id) on delete restrict on update restrict; - - -~~~ - - - -- Gitee From 49115c2b4e4622d1ea3016c236161c351ac853b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A2=A6=E6=A2=A6?= <3195337478@qq.com> Date: Tue, 12 Sep 2023 14:55:14 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E9=99=88=E6=A2=A6=E6=A2=A6=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈梦梦 <3195337478@qq.com> --- .../20230912.md" | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 "01 \351\231\210\346\242\246\346\242\246/20230912.md" diff --git "a/01 \351\231\210\346\242\246\346\242\246/20230912.md" "b/01 \351\231\210\346\242\246\346\242\246/20230912.md" new file mode 100644 index 0000000..b18b4f3 --- /dev/null +++ "b/01 \351\231\210\346\242\246\346\242\246/20230912.md" @@ -0,0 +1,239 @@ +2023年09月12日 + +今天复习了一下图书管理系统,但是犯困还是没听见怎么写,然后老师布置了新作业,不知道是不是老师给了一点思路,感觉这个图很快就做出来了。至少不会像图书管理那个一样一塌糊涂,但是还有很多不会的。比如表格关联,数据如何插入,希望明天可以解决今天的问题,那个艺人的表格真的不会插!!!! + + + +后续: + +研究出来了,但是太多了 ,想睡觉,来不及写,这是思路 + +### ![6302eb986871b6640c8e7e7d62277a6](C:\Users\陈梦梦\AppData\Local\Temp\WeChat Files\6302eb986871b6640c8e7e7d62277a6.jpg) + +er图 + +![er](E:\高级数据库\04\er.png) + +~~~mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023-09-12 11:26:47 */ +/*==============================================================*/ +drop database if exists zy; +create database zy charset utf8; +use zy; + +drop table if exists artist; + +drop table if exists country; + +drop table if exists director; + +drop table if exists language; + +drop table if exists movie; + +drop table if exists protagonist; + +drop table if exists rating; + +drop table if exists review; + +drop table if exists scriptwriter; + +drop table if exists type; + +drop table if exists user; + +/*==============================================================*/ +/* Table: artist */ +/*==============================================================*/ +create table artist +( + art_id int not null, + movie_id int not null, + pro_id int not null, + dir_id int not null, + scr_id int not null, + art_name char(10) not null, + art_work char(10) not null, + primary key (art_id) +); + +/*==============================================================*/ +/* Table: country */ +/*==============================================================*/ +create table country +( + cou_id int not null, + movie_id int not null, + cou_name char(20) not null, + primary key (cou_id) +); + + +insert into country values +(1,1,"美国,韩国"); +/*==============================================================*/ +/* Table: director */ +/*==============================================================*/ +create table director +( + dir_id int not null, + dir_name char(10) not null, + primary key (dir_id) +); + +insert into director values +(1,'席琳·宋'); +/*==============================================================*/ +/* Table: language */ +/*==============================================================*/ +create table `language` +( + lang_id int not null, + movie_id int not null, + lang char(10) not null, + primary key (lang_id) +); +insert into `language` values +(1,1,'英语,韩语'); + +/*==============================================================*/ +/* Table: movie */ +/*==============================================================*/ +create table movie +( + movie_id int not null, + movie_name char(20) not null, + release_date date not null, + length int not null, + primary key (movie_id) +); +insert into movie values +(1,'过往人生','2023-01-21',160); + +/*==============================================================*/ +/* Table: protagonist */ +/*==============================================================*/ +create table protagonist +( + pro_id int not null, + pro_name char(10) not null, + primary key (pro_id) +); +insert into protagonist values +(1,' 格蕾塔·李'), +(2,' 刘台午'), +(3,' 约翰·马加罗'), +(4,'文胜雅'), +(5,'尹智慧 '); + +/*==============================================================*/ +/* Table: rating */ +/*==============================================================*/ +create table rating +( + movie_id int not null, + user_id int not null, + user_rating char(10) not null, + primary key (movie_id, user_id) +); + +insert into rating values +(1,1,'90分'); + +/*==============================================================*/ +/* Table: review */ +/*==============================================================*/ +create table review +( + re_id int not null, + user_id int not null, + movie_id int not null, + re_name char(20) not null, + re_text char(100) not null, + re_appraise int not null, + primary key (re_id) +); +insert into review values +(1,1,1,'男人总是留守过去,女人总是面向未来','在柏林的映后采访中,一个记者提了这样一个问题:为什么在这部电影里,男人总是承受、感性、饱含爱的那一方,而女人则冷静、选择活在当下、坚持走在自己的路上',5); + + +/*==============================================================*/ +/* Table: scriptwriter */ +/*==============================================================*/ +create table scriptwriter +( + scr_id int not null, + scr_name char(10) not null, + primary key (scr_id) +); +insert into scriptwriter values +(1,'席琳·宋'); + + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + type_id int not null, + movie_id int not null, + type_name char(10) not null, + primary key (type_id) +); +insert into type values +(1,1,'剧情 / 爱情'); + + +/*==============================================================*/ +/* Table: user */ +/*==============================================================*/ +create table `user` +( + user_id int not null, + user_name char(10) not null, + primary key (user_id) +); +insert into `user` values +(1,'陈梦梦'); + +alter table artist add constraint FK_Relationship_4 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table artist add constraint FK_Relationship_5 foreign key (pro_id) + references protagonist (pro_id) on delete restrict on update restrict; + +alter table artist add constraint FK_Relationship_6 foreign key (dir_id) + references director (dir_id) on delete restrict on update restrict; + +alter table artist add constraint FK_Relationship_7 foreign key (scr_id) + references scriptwriter (scr_id) on delete restrict on update restrict; + +alter table country add constraint FK_Relationship_3 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table language add constraint FK_Relationship_2 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table rating add constraint FK_Relationship_11 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table rating add constraint FK_Relationship_12 foreign key (user_id) + references user (user_id) on delete restrict on update restrict; + +alter table review add constraint FK_Relationship_10 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table review add constraint FK_Relationship_9 foreign key (user_id) + references user (user_id) on delete restrict on update restrict; + +alter table type add constraint FK_Relationship_1 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + + +~~~ + + + -- Gitee