diff --git "a/25\351\231\210\344\275\263\347\202\234/9\346\234\21012\346\227\245\344\275\234\344\270\232.md" "b/25\351\231\210\344\275\263\347\202\234/9\346\234\21012\346\227\245\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..8438cac9118d7288310a167011425036dd239053 --- /dev/null +++ "b/25\351\231\210\344\275\263\347\202\234/9\346\234\21012\346\227\245\344\275\234\344\270\232.md" @@ -0,0 +1,221 @@ +# 作业 + + + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/13 12:26:16 */ +/*==============================================================*/ +create database sxh charset utf8; + +use sxh; + +drop table if exists Relationship_5; + +drop table if exists Relationship_8; + +drop table if exists Relationship_9; + +drop table if exists address; + +drop table if exists audience; + +drop table if exists comment; + +drop table if exists directortable; + +drop table if exists language; + +drop table if exists list; + +drop table if exists movie; + +drop table if exists profile; + +drop table if exists review; + +drop table if exists type; + +/*==============================================================*/ +/* Table: Relationship_5 */ +/*==============================================================*/ +create table Relationship_5 +( + t_id int not null, + movieId int not null, + primary key (t_id, movieId) +); + +/*==============================================================*/ +/* Table: Relationship_8 */ +/*==============================================================*/ +create table Relationship_8 +( + movieId int not null, + l_id int not null, + primary key (movieId, l_id) +); + +/*==============================================================*/ +/* Table: Relationship_9 */ +/*==============================================================*/ +create table Relationship_9 +( + list_id int not null, + m_id int not null, + primary key (list_id, m_id) +); + +/*==============================================================*/ +/* Table: address */ +/*==============================================================*/ +create table address +( + ad_id int not null, + movieId int not null, + ad_name varchar(20) not null, + primary key (ad_id) +); + +/*==============================================================*/ +/* Table: audience */ +/*==============================================================*/ +create table audience +( + m_id int not null, + a_name varchar(20) not null, + a_tel char(11) not null, + primary key (m_id) +); + +/*==============================================================*/ +/* Table: comment */ +/*==============================================================*/ +create table comment +( + movieId int not null, + c_id char(10), + char(10), + char(10) +); + +/*==============================================================*/ +/* Table: directortable */ +/*==============================================================*/ +create table directortable +( + d_id int not null, + director varchar(20) not null, + d_name varchar(5) not null, + d_age varchar(3) not null, + d_add varchar(50) not null, + primary key (d_id) +); + +/*==============================================================*/ +/* Table: language */ +/*==============================================================*/ +create table language +( + l_id int not null, + l_type varchar(20) not null, + primary key (l_id) +); + +/*==============================================================*/ +/* Table: list */ +/*==============================================================*/ +create table list +( + list_id int not null, + list_name varchar(20) not null, + recommend varchar(50) not null, + primary key (list_id) +); + +/*==============================================================*/ +/* Table: movie */ +/*==============================================================*/ +create table movie +( + movieId int not null, + m_id int, + director varchar(20) not null, + movieName varchar(20) not null, + "release" date not null, + duration time not null, + primary key (movieId) +); + +/*==============================================================*/ +/* Table: profile */ +/*==============================================================*/ +create table profile +( + director varchar(20) not null, + scripwriter varchar(20) not null, + actor varchar(20) not null, + score int not null, + primary key (director) +); + +/*==============================================================*/ +/* Table: review */ +/*==============================================================*/ +create table review +( + r_id int not null, + movieId int not null, + ranking int not null, + review varchar(100) not null, + primary key (r_id) +); + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + t_id int not null, + action varchar(20) not null, + love varchar(20) not null, + science varchar(20) not null, + terror varchar(20) not null, + primary key (t_id) +); + +alter table Relationship_5 add constraint FK_Relationship_10 foreign key (movieId) + references movie (movieId) on delete restrict on update restrict; + +alter table Relationship_5 add constraint FK_Relationship_5 foreign key (t_id) + references type (t_id) on delete restrict on update restrict; + +alter table Relationship_8 add constraint FK_Relationship_11 foreign key (l_id) + references language (l_id) on delete restrict on update restrict; + +alter table Relationship_8 add constraint FK_Relationship_8 foreign key (movieId) + references movie (movieId) on delete restrict on update restrict; + +alter table Relationship_9 add constraint FK_Relationship_12 foreign key (m_id) + references audience (m_id) on delete restrict on update restrict; + +alter table Relationship_9 add constraint FK_Relationship_9 foreign key (list_id) + references list (list_id) on delete restrict on update restrict; + +alter table address add constraint FK_Relationship_3 foreign key (movieId) + references movie (movieId) on delete restrict on update restrict; + +alter table comment add constraint FK_Relationship_4 foreign key (movieId) + references movie (movieId) on delete restrict on update restrict; + +alter table directortable add constraint FK_Relationship_7 foreign key (director) + references profile (director) on delete restrict on update restrict; + +alter table movie add constraint FK_Relationship_1 foreign key (m_id) + references audience (m_id) on delete restrict on update restrict; + +alter table movie add constraint FK_Relationship_6 foreign key (director) + references profile (director) on delete restrict on update restrict; + +alter table review add constraint FK_Relationship_2 foreign key (movieId) + references movie (movieId) on delete restrict on update restrict; \ No newline at end of file