diff --git "a/21 \345\215\242\344\272\250\350\200\200/\347\224\265\345\275\261\347\275\221\347\253\231\346\225\260\346\215\256\345\272\223.markdown" "b/21 \345\215\242\344\272\250\350\200\200/\347\224\265\345\275\261\347\275\221\347\253\231\346\225\260\346\215\256\345\272\223.markdown" new file mode 100644 index 0000000000000000000000000000000000000000..9ef32cc97a3d868649eba5c3a4cc613e62a359c8 --- /dev/null +++ "b/21 \345\215\242\344\272\250\350\200\200/\347\224\265\345\275\261\347\275\221\347\253\231\346\225\260\346\215\256\345\272\223.markdown" @@ -0,0 +1,137 @@ +![](https://s2.loli.net/2023/09/13/qR8Qv3GLXerBpS1.png) + +---------------------------------------------------------------------------------------------------------- + +``` mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/13 12:34:05 */ +/*==============================================================*/ + +create database movie_db charset utf8; +use movie_db; + +drop table if exists account; + +drop table if exists film_review; + +drop table if exists member; + +drop table if exists movie; + +drop table if exists scomment; + +drop table if exists type; + +drop table if exists watch; + +/*==============================================================*/ +/* Table: account */ +/*==============================================================*/ +create table account +( + account_id int not null auto_increment, + account_name varchar(20) not null, + primary key (account_id) +); + +/*==============================================================*/ +/* Table: film_review */ +/*==============================================================*/ +create table film_review +( + account_id int, + movie_id int, + film_review_Score decimal(2), + film_review_caption char(10), + film_review_comment char(10), + film_review_datetime datetime +); + +/*==============================================================*/ +/* Table: member */ +/*==============================================================*/ +create table member +( + member_director char(10) not null, + member_screenwriter char(10) not null, + member_actor char(10) not null, + movie_id int, + primary key (member_director, member_screenwriter, member_actor) +); + +/*==============================================================*/ +/* Table: movie */ +/*==============================================================*/ +create table movie +( + movie_id int not null auto_increment, + movie_name varchar(20) not null, + movie_country varchar(10) not null, + movie_language varchar(10) not null, + movie_release_date char(10) not null, + movie_time int not null, + movie_alternate_name varchar(20) not null, + IMDb varchar(20) not null, + movie_introduce text, + primary key (movie_id) +); + +/*==============================================================*/ +/* Table: scomment */ +/*==============================================================*/ +create table scomment +( + scoment_lable varchar(20), + scomment_review text, + scomment_time datetime, + scomment_id int not null auto_increment, + account_id int, + watch_id int, + primary key (scomment_id) +); + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + type_id int not null auto_increment, + movie_id int, + tyoe_name char(2) not null, + primary key (type_id) +); + +/*==============================================================*/ +/* Table: watch */ +/*==============================================================*/ +create table watch +( + watch_id int not null auto_increment, + watch_type char(2) not null, + primary key (watch_id) +); + +alter table film_review add constraint FK_影评 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table film_review add constraint FK_评论 foreign key (account_id) + references account (account_id) on delete restrict on update restrict; + +alter table member add constraint FK_制作 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table scomment add constraint FK_短评账户 foreign key (account_id) + references account (account_id) on delete restrict on update restrict; + +alter table scomment add constraint FK_观看情况 foreign key (watch_id) + references watch (watch_id) on delete restrict on update restrict; + +alter table type add constraint FK_属于 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + + +``` + + +