{"actor": {"columns": [[0, "aid", "INT", 0, null, 1], [1, "gender", "TEXT", 0, null, 0], [2, "name", "TEXT", 0, null, 0], [3, "nationality", "TEXT", 0, null, 0], [4, "birth_city", "TEXT", 0, null, 0], [5, "birth_year", "INT", 0, null, 0]], "primary_keys": ["aid"], "foreign_keys": [], "unique_constraints": [[[0, 0, "aid"]]], "check_constraints": []}, "copyright": {"columns": [[0, "id", "INT", 0, null, 1], [1, "msid", "INT", 0, null, 0], [2, "cid", "INT", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "cast": {"columns": [[0, "id", "INT", 0, null, 1], [1, "msid", "INT", 0, null, 0], [2, "aid", "INT", 0, null, 0], [3, "role", "INT", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "copyright", "msid", "msid", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "actor", "aid", "aid", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "genre": {"columns": [[0, "gid", "INT", 0, null, 1], [1, "genre", "TEXT", 0, null, 0]], "primary_keys": ["gid"], "foreign_keys": [], "unique_constraints": [[[0, 0, "gid"]]], "check_constraints": []}, "classification": {"columns": [[0, "id", "INT", 0, null, 1], [1, "msid", "INT", 0, null, 0], [2, "gid", "INT", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "copyright", "msid", "msid", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "genre", "gid", "gid", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "company": {"columns": [[0, "id", "INT", 0, null, 1], [1, "name", "TEXT", 0, null, 0], [2, "country_code", "TEXT", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "director": {"columns": [[0, "did", "INT", 0, null, 1], [1, "gender", "TEXT", 0, null, 0], [2, "name", "TEXT", 0, null, 0], [3, "nationality", "TEXT", 0, null, 0], [4, "birth_city", "TEXT", 0, null, 0], [5, "birth_year", "INT", 0, null, 0]], "primary_keys": ["did"], "foreign_keys": [], "unique_constraints": [[[0, 0, "did"]]], "check_constraints": []}, "producer": {"columns": [[0, "pid", "INT", 0, null, 1], [1, "gender", "TEXT", 0, null, 0], [2, "name", "TEXT", 0, null, 0], [3, "nationality", "TEXT", 0, null, 0], [4, "birth_city", "TEXT", 0, null, 0], [5, "birth_year", "INT", 0, null, 0]], "primary_keys": ["pid"], "foreign_keys": [], "unique_constraints": [[[0, 0, "pid"]]], "check_constraints": []}, "directed_by": {"columns": [[0, "id", "INT", 0, null, 1], [1, "msid", "INT", 0, null, 0], [2, "did", "INT", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "director", "did", "did", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "copyright", "msid", "msid", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "keyword": {"columns": [[0, "id", "INT", 0, null, 1], [1, "keyword", "TEXT", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "made_by": {"columns": [[0, "id", "INT", 0, null, 1], [1, "msid", "INT", 0, null, 0], [2, "pid", "INT", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "producer", "pid", "pid", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "copyright", "msid", "msid", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "movie": {"columns": [[0, "mid", "INT", 0, null, 1], [1, "title", "TEXT", 0, null, 0], [2, "release_year", "INT", 0, null, 0], [3, "title_aka", "TEXT", 0, null, 0], [4, "budget", "TEXT", 0, null, 0]], "primary_keys": ["mid"], "foreign_keys": [], "unique_constraints": [[[0, 0, "mid"]]], "check_constraints": []}, "tags": {"columns": [[0, "id", "INT", 0, null, 1], [1, "msid", "INT", 0, null, 0], [2, "kid", "INT", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "keyword", "kid", "kid", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "copyright", "msid", "msid", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "tv_series": {"columns": [[0, "sid", "INT", 0, null, 1], [1, "title", "TEXT", 0, null, 0], [2, "release_year", "INT", 0, null, 0], [3, "num_of_seasons", "INT", 0, null, 0], [4, "num_of_episodes", "INT", 0, null, 0], [5, "title_aka", "TEXT", 0, null, 0], [6, "budget", "TEXT", 0, null, 0]], "primary_keys": ["sid"], "foreign_keys": [], "unique_constraints": [[[0, 0, "sid"]]], "check_constraints": []}, "writer": {"columns": [[0, "wid", "INT", 0, null, 1], [1, "gender", "TEXT", 0, null, 0], [2, "name", "INT", 0, null, 0], [3, "nationality", "INT", 0, null, 0], [4, "num_of_episodes", "INT", 0, null, 0], [5, "birth_city", "TEXT", 0, null, 0], [6, "birth_year", "INT", 0, null, 0]], "primary_keys": ["wid"], "foreign_keys": [], "unique_constraints": [[[0, 0, "wid"]]], "check_constraints": []}, "written_by": {"columns": [[0, "id", "INT", 0, null, 0], [1, "msid", "INT", 0, null, 0], [2, "wid", "INT", 0, null, 0]], "primary_keys": [], "foreign_keys": [[0, 0, "writer", "wid", "wid", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "copyright", "msid", "msid", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}}
CREATE TABLE actor (
    aid INT   PRIMARY KEY,
    gender TEXT,
    name TEXT,
    nationality TEXT,
    birth_city TEXT,
    birth_year INT,
    UNIQUE (aid)
);

CREATE TABLE copyright (
    id INT   PRIMARY KEY,
    msid INT,
    cid INT,
    UNIQUE (id)
);

CREATE TABLE cast (
    id INT   PRIMARY KEY,
    msid INT,
    aid INT,
    role INT,
    UNIQUE (id),
    FOREIGN KEY (msid) REFERENCES copyright(msid),
    FOREIGN KEY (aid) REFERENCES actor(aid)
);

CREATE TABLE genre (
    gid INT   PRIMARY KEY,
    genre TEXT,
    UNIQUE (gid)
);

CREATE TABLE classification (
    id INT   PRIMARY KEY,
    msid INT,
    gid INT,
    UNIQUE (id),
    FOREIGN KEY (msid) REFERENCES copyright(msid),
    FOREIGN KEY (gid) REFERENCES genre(gid)
);

CREATE TABLE company (
    id INT   PRIMARY KEY,
    name TEXT,
    country_code TEXT,
    UNIQUE (id)
);

CREATE TABLE director (
    did INT   PRIMARY KEY,
    gender TEXT,
    name TEXT,
    nationality TEXT,
    birth_city TEXT,
    birth_year INT,
    UNIQUE (did)
);

CREATE TABLE producer (
    pid INT   PRIMARY KEY,
    gender TEXT,
    name TEXT,
    nationality TEXT,
    birth_city TEXT,
    birth_year INT,
    UNIQUE (pid)
);

CREATE TABLE directed_by (
    id INT   PRIMARY KEY,
    msid INT,
    did INT,
    UNIQUE (id),
    FOREIGN KEY (did) REFERENCES director(did),
    FOREIGN KEY (msid) REFERENCES copyright(msid)
);

CREATE TABLE keyword (
    id INT   PRIMARY KEY,
    keyword TEXT,
    UNIQUE (id)
);

CREATE TABLE made_by (
    id INT   PRIMARY KEY,
    msid INT,
    pid INT,
    UNIQUE (id),
    FOREIGN KEY (pid) REFERENCES producer(pid),
    FOREIGN KEY (msid) REFERENCES copyright(msid)
);

CREATE TABLE movie (
    mid INT   PRIMARY KEY,
    title TEXT,
    release_year INT,
    title_aka TEXT,
    budget TEXT,
    UNIQUE (mid)
);

CREATE TABLE tags (
    id INT   PRIMARY KEY,
    msid INT,
    kid INT,
    UNIQUE (id),
    FOREIGN KEY (kid) REFERENCES keyword(kid),
    FOREIGN KEY (msid) REFERENCES copyright(msid)
);

CREATE TABLE tv_series (
    sid INT   PRIMARY KEY,
    title TEXT,
    release_year INT,
    num_of_seasons INT,
    num_of_episodes INT,
    title_aka TEXT,
    budget TEXT,
    UNIQUE (sid)
);

CREATE TABLE writer (
    wid INT   PRIMARY KEY,
    gender TEXT,
    name INT,
    nationality INT,
    num_of_episodes INT,
    birth_city TEXT,
    birth_year INT,
    UNIQUE (wid)
);

CREATE TABLE written_by (
    id INT,
    msid INT,
    wid INT,
    FOREIGN KEY (wid) REFERENCES writer(wid),
    FOREIGN KEY (msid) REFERENCES copyright(msid)
);