-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump.sql
More file actions
141 lines (123 loc) · 2.54 KB
/
dump.sql
File metadata and controls
141 lines (123 loc) · 2.54 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
create table genres
(
genreid serial not null
constraint genres_pkey
primary key,
genrename varchar(40) not null
)
;
create unique index genres_genreid_uindex
on genres (genreid)
;
create unique index genres_genrename_uindex
on genres (genrename)
;
create table movie
(
movieid serial not null
constraint movie_pkey
primary key,
name varchar(100) not null,
releaseyear integer,
rating numeric,
movielength integer,
description varchar(300)
)
;
create table moviegenres
(
moviegenres serial not null
constraint moviegenres_pkey
primary key,
movieid serial not null
constraint moviegenres_movie_movieid_fk
references movie,
genreid serial not null
constraint moviegenres_genres_genreid_fk
references genres
)
;
create unique index moviegenres_moviegenres_uindex
on moviegenres (moviegenres)
;
create table people
(
peopleid serial not null
constraint people_pkey
primary key,
firstname varchar(50) not null,
lastname varchar(50) not null,
birth date
)
;
create unique index people_peopleid_uindex
on people (peopleid)
;
create table awards
(
awardsid serial not null
constraint awards_pkey
primary key,
name varchar(100) not null
)
;
create unique index awards_awardsid_uindex
on awards (awardsid)
;
create unique index awards_name_uindex
on awards (name)
;
create table moviepeople
(
moviepeopleid serial not null
constraint moviepeople_pkey
primary key,
movieid serial not null
constraint moviepeople_movie_movieid_fk
references movie,
peopleid serial not null
constraint moviepeople_people_peopleid_fk
references people,
professionid serial not null,
awardid serial
constraint moviepeople_awards_awardsid_fk
references awards
)
;
create unique index moviepeople_moviepeopleid_uindex
on moviepeople (moviepeopleid)
;
create table movieawards
(
movieawardsid serial not null
constraint movieawards_pkey
primary key,
movieid serial not null
constraint movieawards_movie_movieid_fk
references movie,
awardid serial not null
constraint movieawards_awards_awardsid_fk
references awards
)
;
create unique index movieawards_movieawardsid_uindex
on movieawards (movieawardsid)
;
create table profession
(
professionid serial not null
constraint profession_pkey
primary key,
name varchar(70) not null
)
;
create unique index profession_professionid_uindex
on profession (professionid)
;
create unique index profession_name_uindex
on profession (name)
;
alter table moviepeople
add constraint moviepeople_profession_professionid_fk
foreign key (professionid) references profession
;