-- Schema: bird__law_episode
CREATE SCHEMA IF NOT EXISTS "bird__law_episode";

-- Table: Award
CREATE TABLE "bird__law_episode"."Award" (
    "award_id" BIGINT NOT NULL,
    "organization" TEXT,
    "year" BIGINT,
    "award_category" TEXT,
    "award" TEXT,
    "series" TEXT,
    "episode_id" TEXT,
    "person_id" TEXT,
    "role" TEXT,
    "result" TEXT,
    CONSTRAINT "Award_pkey" PRIMARY KEY ("award_id")
);

-- Table: Credit
CREATE TABLE "bird__law_episode"."Credit" (
    "episode_id" TEXT NOT NULL,
    "person_id" TEXT NOT NULL,
    "category" TEXT,
    "role" TEXT,
    "credited" TEXT,
    CONSTRAINT "Credit_pkey" PRIMARY KEY ("episode_id", "person_id")
);

-- Table: Episode
CREATE TABLE "bird__law_episode"."Episode" (
    "episode_id" TEXT NOT NULL,
    "series" TEXT,
    "season" BIGINT,
    "episode" BIGINT,
    "number_in_series" BIGINT,
    "title" TEXT,
    "summary" TEXT,
    "air_date" DATE,
    "episode_image" TEXT,
    "rating" DOUBLE PRECISION,
    "votes" BIGINT,
    CONSTRAINT "Episode_pkey" PRIMARY KEY ("episode_id")
);

-- Table: Keyword
CREATE TABLE "bird__law_episode"."Keyword" (
    "episode_id" TEXT NOT NULL,
    "keyword" TEXT NOT NULL,
    CONSTRAINT "Keyword_pkey" PRIMARY KEY ("episode_id", "keyword")
);

-- Table: Person
CREATE TABLE "bird__law_episode"."Person" (
    "person_id" TEXT NOT NULL,
    "name" TEXT,
    "birthdate" DATE,
    "birth_name" TEXT,
    "birth_place" TEXT,
    "birth_region" TEXT,
    "birth_country" TEXT,
    "height_meters" DOUBLE PRECISION,
    "nickname" TEXT,
    CONSTRAINT "Person_pkey" PRIMARY KEY ("person_id")
);

-- Table: Vote
CREATE TABLE "bird__law_episode"."Vote" (
    "episode_id" TEXT,
    "stars" BIGINT,
    "votes" BIGINT,
    "percent" DOUBLE PRECISION
);

-- Foreign Keys
ALTER TABLE "bird__law_episode"."Award" ADD CONSTRAINT "fk_Award_1" FOREIGN KEY ("episode_id") REFERENCES "bird__law_episode"."Episode" ("episode_id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "bird__law_episode"."Credit" ADD CONSTRAINT "fk_Credit_0" FOREIGN KEY ("person_id") REFERENCES "bird__law_episode"."Person" ("person_id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "bird__law_episode"."Credit" ADD CONSTRAINT "fk_Credit_1" FOREIGN KEY ("episode_id") REFERENCES "bird__law_episode"."Episode" ("episode_id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "bird__law_episode"."Keyword" ADD CONSTRAINT "fk_Keyword_0" FOREIGN KEY ("episode_id") REFERENCES "bird__law_episode"."Episode" ("episode_id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "bird__law_episode"."Vote" ADD CONSTRAINT "fk_Vote_0" FOREIGN KEY ("episode_id") REFERENCES "bird__law_episode"."Episode" ("episode_id") ON DELETE NO ACTION ON UPDATE NO ACTION;
