diff --git "a/19\345\275\255\345\213\207\346\226\214/\347\254\224\350\256\260/\344\275\234\344\270\232.md" "b/19\345\275\255\345\213\207\346\226\214/\347\254\224\350\256\260/\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..5d14eeab2034413adbf550cb036af7b4e100b0dc --- /dev/null +++ "b/19\345\275\255\345\213\207\346\226\214/\347\254\224\350\256\260/\344\275\234\344\270\232.md" @@ -0,0 +1,148 @@ +# 作业 9/12 + + + +```MYSQL +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023-09-12 11:33:36 */ +/*==============================================================*/ +CREATE DATABASE film charset utf8; +use film; + +drop table if exists Commenttype; + +drop table if exists `comment`; + +drop table if exists commentssection; + +drop table if exists country; + +drop table if exists `language`; + +drop table if exists movie; + +drop table if exists movieteam; + +drop table if exists movietypes; + +/*==============================================================*/ +/* Table: Commenttype */ +/*==============================================================*/ +create table Commenttype +( + Commenttype_id int not null auto_increment, + comment_id int not null, + Commenttype_name varchar(10) not null, + primary key (Commenttype_id) +); + +/*==============================================================*/ +/* Table: comment */ +/*==============================================================*/ +create table `comment` +( + comment_id int not null auto_increment, + comment_user varchar(10) not null, + comment_time datetime not null, + comment_content varchar(255) not null, + primary key (comment_id) +); + +/*==============================================================*/ +/* Table: commentssection */ +/*==============================================================*/ +create table commentssection +( + commentssection_id int not null auto_increment, + movie_id int not null, + commentssection_theme varchar(20) not null, + commentssection_source varchar(5) not null, + commentssection_time datetime not null, + primary key (commentssection_id) +); + +/*==============================================================*/ +/* Table: country */ +/*==============================================================*/ +create table country +( + country_id int not null auto_increment, + country_name varchar(10) not null, + primary key (country_id) +); + +/*==============================================================*/ +/* Table: language */ +/*==============================================================*/ +create table language +( + language_id int not null auto_increment, + language varchar(10) not null, + primary key (language_id) +); + +/*==============================================================*/ +/* Table: movie */ +/*==============================================================*/ +create table movie +( + movie_id int not null auto_increment, + movietypes_id int not null, + country_id int not null, + comment_id int not null, + language_id int not null, + movie_name varchar(20) not null, + movie_time int not null, + movie_alias varchar(20) not null, + movie_data datetime not null, + TMDB varchar(20) not null, + movie_intro varchar(255) not null, + movie_awards varchar(100) not null, + movie_score decimal(2,1) not null, + primary key (movie_id) +); + +/*==============================================================*/ +/* Table: movieteam */ +/*==============================================================*/ +create table movieteam +( + movieteam_id int not null auto_increment, + movie_id int not null, + movieteam_name varchar(10) not null, + movieteam_age char(1) not null, + movieteam_status varchar(10) not null, + primary key (movieteam_id) +); + +/*==============================================================*/ +/* Table: movietypes */ +/*==============================================================*/ +create table movietypes +( + movietypes_id int not null auto_increment, + movietypes_name varchar(5) not null, + primary key (movietypes_id) +); + +alter table Commenttype add constraint FK_Relationship_5 foreign key (comment_id) + references comment (comment_id) on delete restrict on update restrict; + +alter table commentssection add constraint FK_Relationship_7 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; + +alter table movie add constraint FK_Relationship_1 foreign key (movietypes_id) + references movietypes (movietypes_id) on delete restrict on update restrict; + +alter table movie add constraint FK_Relationship_2 foreign key (country_id) + references country (country_id) on delete restrict on update restrict; + +alter table movie add constraint FK_Relationship_3 foreign key (language_id) + references language (language_id) on delete restrict on update restrict; + +alter table movie add constraint FK_Relationship_4 foreign key (comment_id) + references comment (comment_id) on delete restrict on update restrict; + +alter table movieteam add constraint FK_Relationship_6 foreign key (movie_id) + references movie (movie_id) on delete restrict on update restrict; \ No newline at end of file