From 355bee542644d8afc4cc04f42d4fd68c24b7389d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=99=93=E7=81=BF?= <2447149492@qq.com> Date: Tue, 12 Sep 2023 04:44:15 +0000 Subject: [PATCH] =?UTF-8?q?=E9=99=88=E6=99=93=E7=81=BF=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈晓灿 <2447149492@qq.com> --- .../20230912 \350\261\206\347\223\243.md" | 186 ++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 "26\351\231\210\346\231\223\347\201\277/20230912 \350\261\206\347\223\243.md" diff --git "a/26\351\231\210\346\231\223\347\201\277/20230912 \350\261\206\347\223\243.md" "b/26\351\231\210\346\231\223\347\201\277/20230912 \350\261\206\347\223\243.md" new file mode 100644 index 0000000..c5641e7 --- /dev/null +++ "b/26\351\231\210\346\231\223\347\201\277/20230912 \350\261\206\347\223\243.md" @@ -0,0 +1,186 @@ +笔记: + +今天练习了如何制作电影数据库的ER图 + +作业: + +~~~mysql +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/12 8:08:24 */ +/*==============================================================*/ + +create database movie charset utf8; +use movie; + +drop table if exists cnxy; + +drop table if exists comment; + +drop table if exists film; + +drop table if exists people; + +drop table if exists post; + +drop table if exists type; + +drop table if exists user; + +/*==============================================================*/ +/* Table: cnxy */ +/*==============================================================*/ +create table cnxy +( + us_id int not null, + ty_id int not null, # 想看的电影类型 + cn_tj varchar(11), # 推荐电影 + primary key (us_id, ty_id) + +); +insert into cnxy values (1,5,'芭比 Barbie'), + (2,9,'宇宙探索编辑部'), + (3,7,'碟中谍7:致命清算(上)'), + (4,6,'楚门的世界'), + (5,13,'摔跤吧!爸爸 Dangal'); +-- + +-- insert into +/*==============================================================*/ +/* Table: comment */ +/*==============================================================*/ +create table comment +( + fi_id int not null, + us_id int not null, + com_score int not null, + com_content varchar(11) not null, + com_jx varchar(11), + com_hf varchar(11), + primary key (fi_id, us_id) +); +insert into + +/*==============================================================*/ +/* Table: film */ +/*==============================================================*/ +create table film +( + fi_id int not null auto_increment, + ty_id int not null, + fi_name varchar(11) not null, + fi_language varchar(11) not null, + fi_county varchar(11) not null, + fi_date date not null, + fi_time time not null, + fi_con varchar(11) not null, + primary key (fi_id) +); + +insert into film values + (1,5,'武状元苏乞儿','粤语','中国香港','1992-12-17','01:30:00','123'), + (2,5,'济公','粤语','中国香港','1993-07-29','01:29:00','123'), + (3,5,'关于我和鬼变成家人的那件事','汉语普通话 / 闽南语','中国台湾','12023-02-10','02:29:00','吴明翰(许光汉 饰)是一名脾气耿直的警察,一次在出警中,他偶然捡到了地上的红包,哪知道被牵扯到了一桩冥婚之中,而他要结婚的对象,竟然是名叫毛邦羽(林柏宏 饰)的男人。吴明翰虽然内心一百个不情愿,但很快他就发现,如果不完婚,那么坏运气会一直跟随着他,无奈之下,吴明翰只得在灵堂中和毛邦宇举行了仪式。 +  第二天,毛邦宇的鬼魂出现在了吴明翰的面前,想要结束这场荒唐的闹剧,吴明翰必须帮助毛邦宇完成遗愿,他给动物慈善组织捐款、去探望毛邦宇在世时的男友、查找导致毛邦宇死亡的车祸事件真相,在此过程中,吴明翰和毛邦宇从“假夫妻”变成了“真朋友”。'), + (4,5,'芭比 Barbie','英语','加拿大 / 美国',' 2023-07-21','02:22:00','在芭比乐园里,各种各样的芭比和肯每天都过着童话般100%完美的生活。但是某一天,芭比(玛格特·罗比 Margot Robbie 饰)发现自己的生活开始有了变化——比如她的一天不再一帆风顺,她开始思考死亡的意义,甚至她的双脚也不再是完美的高跟鞋形——她竟然脚掌落地了!接连出现的不完美打破了芭比乐园的平静,意识到存在感危机的芭比被迫前往真实世界探寻真相,肯(瑞恩·高斯林 Ryan Gosling 饰)也一路同行,一场大冒险就此开启。'), + (5,5,'八角笼中','汉语普通话 / 四川方言','中国大陆','2023-07-06','02:19:00','电影讲述了向腾辉(王宝强 饰)倾注心血想把当地无人照料的孩子培养成才,这让生活本没有出路的孩子们看到了一丝通向未来的曙光。然而,随着往日的表演视频被爆出,这些“残忍、血腥”的画面刺激了不明真相的人们的神经。一夜之间,舆论开始发酵。向腾辉的生活、孩子们的前途都陷入到人们以善良为名编织的大网中,让他们难以挣脱,重回泥沼,关于未来,他们的“出路”又将在哪……'); + +/*==============================================================*/ +/* Table: people */ +/*==============================================================*/ + create table people +( + pe_id int not null auto_increment, + pe_name varchar(11) not null, + pe_sex char(2) not null, + primary key (pe_id) +); + +insert into people values + (1,'周星驰','男'), + (2,'吴孟达','男'), + (3,'刘德华','男'), + (4,'张曼玉','女'), + (5,'张敏','女'), + (6,'许光汉','男'), + (7,' 林柏宏','男'), + (8,'王净','女'); +/*==============================================================*/ +/* Table: post */ +/*==============================================================*/ +create table post +( + fi_id int not null, + pe_id int not null, + po_career varchar(11) not null, + primary key (fi_id, pe_id) +); + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + ty_id int not null auto_increment, + ty_name varchar(11) not null, + primary key (ty_id) +); + +insert into type values + (1,'末日'), + (2,'科幻'), + (3,'修仙'), + (4,'爱情'), + (5,'喜剧'), + (6,'剧情'), + (7,'动作'), + (8,'奇幻'), + (9,'冒险'), + (10,'玄幻'), + (11,'悬疑'), + (12,'同性'), + (13,'家庭'); + +/*==============================================================*/ +/* Table: user */ +/*==============================================================*/ +create table user +( + us_id int not null auto_increment, + us_name varchar(11) not null, + primary key (us_id) +); + +insert into user values + (1,'谋杀游戏机'), + (2,'小烨'), + (3,'玄长清'), + (4,'方青'), + (5,'申报记者何书桓'); + + + +alter table cnxy add constraint FK_xz foreign key (us_id) + references user (us_id) on delete restrict on update restrict; + +alter table cnxy add constraint FK_xz2 foreign key (ty_id) + references type (ty_id) on delete restrict on update restrict; + +alter table comment add constraint FK_comment foreign key (fi_id) + references film (fi_id) on delete restrict on update restrict; + +alter table comment add constraint FK_comment2 foreign key (us_id) + references user (us_id) on delete restrict on update restrict; + +alter table film add constraint FK_sy foreign key (ty_id) + references type (ty_id) on delete restrict on update restrict; + +alter table post add constraint FK_post foreign key (fi_id) + references film (fi_id) on delete restrict on update restrict; + +alter table post add constraint FK_post2 foreign key (pe_id) + references people (pe_id) on delete restrict on update restrict; +``` +~~~ + -- Gitee