forked from ashwin1111/reel-box-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueries.sql
More file actions
40 lines (37 loc) · 967 Bytes
/
queries.sql
File metadata and controls
40 lines (37 loc) · 967 Bytes
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
create table movie_challenge_users (
id text not null,
name text not null,
created_at TIMESTAMP DEFAULT now() not null,
PRIMARY KEY (id)
);
create table movie_collection (
name text DEFAULT '-',
year text DEFAULT '-',
rating text DEFAULT '-',
actors text DEFAULT '-',
directors text DEFAULT '-',
plot text DEFAULT '-',
runtime text DEFAULT '-',
language text DEFAULT '-',
poster text DEFAULT '-',
user_id text not null,
created_at TIMESTAMP DEFAULT now(),
FOREIGN KEY (user_id) REFERENCES movie_challenge_users (id)
);
-- drop view if EXISTS all_collections;
-- create view all_collections as
select
c.name name_,
c.year year_,
c.rating rating,
c.actors actors,
c.directors directors,
c.plot plot,
c.runtime runtime,
c.language language_,
c.poster poster,
c.user_id user_id_,
c.created_at created_at,
u.name user_name_
from movie_collection c
inner join movie_challenge_users u on c.user_id = u.id;