-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmovie.sql
56 lines (50 loc) · 1.46 KB
/
movie.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
drop table if exists movie;
create table movie (
movie_id integer primary key,
origin varchar(50),
year year,
title varchar(100),
wiki_link varchar(100),
plot text,
imdb_rating decimal,
imdb_votes integer,
rated varchar(5),
rotten_tomato_rating int,
metacritic_rating int
);
drop table if exists director;
create table director (
director_id integer primary key,
name varchar(50)
);
drop table if exists movie_has_director;
create table movie_has_director (
movie_id integer not null,
director_id integer not null,
foreign key (movie_id) references movies (movie_id),
foreign key (director_id) references directors (director_id)
);
drop table if exists genre;
create table genre (
genre_id integer primary key,
name varchar(50)
);
drop table if exists movie_has_genre;
create table movie_has_genre (
movie_id integer not null,
genre_id integer not null,
foreign key (movie_id) references movies (movie_id),
foreign key (genre_id) references genres (genre_id)
);
drop table if exists actor;
create table actor (
actor_id integer primary key,
name varchar(50)
);
drop table if exists movie_has_actor;
create table movie_has_actor (
movie_id integer not null,
actor_id integer not null,
foreign key (movie_id) references movies (movie_id),
foreign key (actor_id) references actors (actor_id)
);