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

-- Table: actors
CREATE TABLE "bird__movielens"."actors" (
    "actorid" BIGINT NOT NULL,
    "a_gender" TEXT NOT NULL,
    "a_quality" BIGINT NOT NULL,
    CONSTRAINT "actors_pkey" PRIMARY KEY ("actorid")
);

-- Table: directors
CREATE TABLE "bird__movielens"."directors" (
    "directorid" BIGINT NOT NULL,
    "d_quality" BIGINT NOT NULL,
    "avg_revenue" BIGINT NOT NULL,
    CONSTRAINT "directors_pkey" PRIMARY KEY ("directorid")
);

-- Table: movies
CREATE TABLE "bird__movielens"."movies" (
    "movieid" BIGINT NOT NULL DEFAULT 0,
    "year" BIGINT NOT NULL,
    "isEnglish" TEXT NOT NULL,
    "country" TEXT NOT NULL,
    "runningtime" BIGINT NOT NULL,
    CONSTRAINT "movies_pkey" PRIMARY KEY ("movieid")
);

-- Table: movies2actors
CREATE TABLE "bird__movielens"."movies2actors" (
    "movieid" BIGINT NOT NULL,
    "actorid" BIGINT NOT NULL,
    "cast_num" BIGINT NOT NULL,
    CONSTRAINT "movies2actors_pkey" PRIMARY KEY ("movieid", "actorid")
);

-- Table: movies2directors
CREATE TABLE "bird__movielens"."movies2directors" (
    "movieid" BIGINT NOT NULL,
    "directorid" BIGINT NOT NULL,
    "genre" TEXT NOT NULL,
    CONSTRAINT "movies2directors_pkey" PRIMARY KEY ("movieid", "directorid")
);

-- Table: u2base
CREATE TABLE "bird__movielens"."u2base" (
    "userid" BIGINT NOT NULL DEFAULT 0,
    "movieid" BIGINT NOT NULL,
    "rating" TEXT NOT NULL,
    CONSTRAINT "u2base_pkey" PRIMARY KEY ("userid", "movieid")
);

-- Table: users
CREATE TABLE "bird__movielens"."users" (
    "userid" BIGINT NOT NULL DEFAULT 0,
    "age" TEXT NOT NULL,
    "u_gender" TEXT NOT NULL,
    "occupation" TEXT NOT NULL,
    CONSTRAINT "users_pkey" PRIMARY KEY ("userid")
);

-- Indexes
CREATE INDEX "avg_revenue" ON "bird__movielens"."directors" ("avg_revenue");
CREATE INDEX "d_quality" ON "bird__movielens"."directors" ("d_quality");
