2023-01-03 14:16:10 +00:00
|
|
|
-- Your SQL goes here
|
2023-01-08 14:58:26 +00:00
|
|
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
|
|
|
2023-01-03 14:16:10 +00:00
|
|
|
CREATE TYPE Release as ENUM ('PUBLIC', 'NONCOMMERCIAL', 'RESEARCH', 'PRIVATE');
|
|
|
|
CREATE TYPE DictGenre as ENUM ('gen', 'lrn', 'ety', 'spe', 'his', 'ort', 'trm');
|
|
|
|
CREATE TYPE AgentLanguageRelation as ENUM ('publisher', 'author');
|
|
|
|
|
|
|
|
CREATE TABLE Languages (
|
2023-01-08 14:58:26 +00:00
|
|
|
id UUID DEFAULT uuid_generate_v4 () PRIMARY KEY,
|
|
|
|
name VARCHAR(255) NOT NULL,
|
2023-01-03 14:16:10 +00:00
|
|
|
native VARCHAR(255),
|
2023-01-03 15:11:43 +00:00
|
|
|
release Release NOT NULL,
|
2023-01-03 14:16:10 +00:00
|
|
|
genre DictGenre[] NOT NULL,
|
|
|
|
abstract TEXT,
|
2023-01-03 15:11:43 +00:00
|
|
|
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
2023-01-03 14:16:10 +00:00
|
|
|
description TEXT,
|
|
|
|
rights TEXT,
|
|
|
|
license TEXT,
|
|
|
|
owner VARCHAR(31)
|
|
|
|
REFERENCES Users(id)
|
|
|
|
ON UPDATE CASCADE
|
|
|
|
ON DELETE CASCADE
|
|
|
|
NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-01-08 14:58:26 +00:00
|
|
|
CREATE TABLE LangTranslatesTo (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
langfrom UUID
|
|
|
|
REFERENCES Languages(id)
|
|
|
|
ON UPDATE CASCADE
|
|
|
|
ON DELETE CASCADE
|
|
|
|
NOT NULL,
|
|
|
|
langto UUID
|
|
|
|
REFERENCES Languages(id)
|
|
|
|
ON UPDATE CASCADE
|
|
|
|
ON DELETE CASCADE
|
|
|
|
NOT NULL
|
|
|
|
);
|
|
|
|
|
2023-01-03 14:16:10 +00:00
|
|
|
CREATE TABLE LangAndAgents (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
agent VARCHAR(31)
|
|
|
|
REFERENCES Users(id)
|
|
|
|
ON UPDATE CASCADE
|
|
|
|
ON DELETE CASCADE
|
|
|
|
NOT NULL,
|
2023-01-08 14:58:26 +00:00
|
|
|
language UUID
|
|
|
|
REFERENCES Languages(id)
|
2023-01-03 14:16:10 +00:00
|
|
|
ON UPDATE CASCADE
|
|
|
|
ON DELETE CASCADE
|
|
|
|
NOT NULL,
|
|
|
|
relationship AgentLanguageRelation NOT NULL
|
|
|
|
);
|
2023-01-18 09:26:45 +00:00
|
|
|
|
|
|
|
CREATE TABLE UserFollowLanguage (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
lang UUID
|
|
|
|
REFERENCES Languages(id)
|
|
|
|
ON UPDATE CASCADE
|
|
|
|
ON DELETE CASCADE
|
|
|
|
NOT NULL,
|
|
|
|
userid VARCHAR(31)
|
|
|
|
REFERENCES Users(id)
|
|
|
|
ON UPDATE CASCADE
|
|
|
|
ON DELETE CASCADE
|
|
|
|
NOT NULL
|
|
|
|
);
|