73 lines
1.6 KiB
SQL
73 lines
1.6 KiB
SQL
DROP TABLE IF EXISTS properties, films, languages, subtitle_lines, subtitles;
|
|
|
|
/**
|
|
Store some information on the application.
|
|
*/
|
|
CREATE TABLE IF NOT EXISTS properties
|
|
(
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
app_key text NOT NULL,
|
|
app_value text NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE (app_key)
|
|
);
|
|
|
|
/**
|
|
Film
|
|
*/
|
|
CREATE TABLE IF NOT EXISTS films
|
|
(
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
imdb_id varchar(10) NOT NULL,
|
|
title text NOT NULL,
|
|
release_date date,
|
|
poster_link text,
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
/**
|
|
Available languages
|
|
*/
|
|
CREATE TABLE IF NOT EXISTS languages
|
|
(
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
alpha3_b char(3) NOT NULL,
|
|
alpha3_t char(3),
|
|
alpha2 char(2),
|
|
english text NOT NULL,
|
|
french text NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE (alpha3_b)
|
|
);
|
|
|
|
/**
|
|
Subtitles
|
|
*/
|
|
CREATE TABLE IF NOT EXISTS subtitles
|
|
(
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
film_id int NOT NULL,
|
|
language_id int NOT NULL,
|
|
importer varchar(37),
|
|
imported_date timestamptz NOT NULL DEFAULT now(),
|
|
UNIQUE (film_id, language_id),
|
|
PRIMARY KEY (id),
|
|
FOREIGN KEY (film_id)
|
|
REFERENCES films (id),
|
|
FOREIGN KEY (language_id)
|
|
REFERENCES languages (id)
|
|
);
|
|
|
|
/**
|
|
Subtitle lines
|
|
*/
|
|
CREATE TABLE IF NOT EXISTS subtitle_lines
|
|
(
|
|
id int GENERATED ALWAYS AS IDENTITY,
|
|
subtitle_id int NOT NULL,
|
|
dialog_line text NOT NULL,
|
|
time_code text NOT NULL,
|
|
PRIMARY KEY (id),
|
|
FOREIGN KEY (subtitle_id)
|
|
REFERENCES subtitles (id)
|
|
); |