
DROP TABLE IF EXISTS movie_query_mapping;
CREATE TABLE movie_query_mapping(
	query_id int,
	movie_id int,
	foreign key(query_id) references movie_queries(query_id),
	foreign key(movie_id) references movie_details(movie_id)
);

DROP TABLE IF EXISTS movie_paths;
CREATE TABLE movie_paths(
	movie_id int not null,
	movie_path text unique not null,
	add_date datetime, -- NOTE: date the path was mapped
	foreign key(movie_id) references movie_details(movie_id)
);

DROP TABLE IF EXISTS movie_genres;
CREATE TABLE movie_genres(
	genre_id integer primary key not null,
	genre_name
);

DROP TABLE IF EXISTS movie_genre_mapping;
CREATE TABLE movie_genre_mapping(
	genre_id integer,
	movie_id integer,
	foreign key(genre_id) references movie_genres(genre_id),
	foreign key(movie_id) references movie_details(movie_id)
);

DROP TABLE IF EXISTS movie_queries;
CREATE TABLE movie_queries(
	query_id integer primary key autoincrement,
	query text,
	year integer
);

DROP TABLE IF EXISTS movie_details;
CREATE TABLE movie_details(
	movie_id primary key not null,
	title text,
	overview text,
	release_date date,
	original_language text,
	poster_path text
);

DROP TABLE IF EXISTS actor_details;
CREATE TABLE actor_details(
	actor_id integer primary key not null,
	name text,
	date_of_birth date,
	poster_path text
);

DROP TABLE IF EXISTS actor_movie_mapping;
CREATE TABLE actor_movie_mapping(
	movie_id integer,
	actor_id integer,
	character_name text,
	foreign key(movie_id) references movie_details(movie_id),
	foreign key(actor_id) references actor_details(actor_id)
);


-- TODO: tv shows

DROP TABLE IF EXISTS tv_queries;
CREATE TABLE tv_queries(
	query text,
	year integer
);
