· 8 years ago · Mar 27, 2018, 07:52 PM
1drop database if exists movies;
2create database movies;
3USE movies;
4
5create table producers
6(
7id int auto_increment primary key,
8address varchar(250) not null,
9bulstat varchar(250) not null
10);
11
12create table studios
13(
14id int auto_increment primary key,
15namestudio varchar(250) not null
16
17);
18create table movie
19(
20
21id int auto_increment primary key,
22title varchar(250) not null,
23actors varchar(250) not null,
24filmstudio varchar(250) not null,
25filmyear year not null,
26duration time not null,
27producer varchar(250) not null,
28budget int not null,
29producer_id int not null ,
30constraint foreign key (producer_id) references producers(id),
31studio_id int not null,
32constraint foreign key (studio_id) references studios(id)
33
34);
35
36create table actors
37(
38
39id int auto_increment primary key,
40birthday date not null,
41actorname varchar(200) not null,
42gender enum ('male','female'),
43filmstudio varchar(200) not null,
44address varchar(200) not null
45
46);
47
48create table movieactors
49(
50 movie_id int not null,
51 actor_id int not null,
52 CONSTRAINT FOREIGN KEY (movie_id)
53 REFERENCES movies(id) ,
54 CONSTRAINT FOREIGN KEY (actor_id)
55 REFERENCES actors(id) ,
56 PRIMARY KEY(movie_id, actor_id)
57);
58
59insert into actors
60values (null,19-08-1978,'Brad Pitt','male','20TH FOX','Malibu beach'),
61 (null,19-08-1978,'Angeline Jolie','female','20TH FOX','Malibu beach'),
62 (null,14-05-1970,'Jenifer Aninston','female','20TH FOX','Malibu beach'),
63 (null,22-11-1988,'Kit Harrington','male','20TH FOX','Malibu beach'),
64 (null,24-09-1972,'Dwayne Jonson','male','20TH FOX','Malibu beach')