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

-- Table: car_makers
CREATE TABLE "spider__car_1"."car_makers" (
    "Id" BIGINT NOT NULL,
    "Maker" TEXT,
    "FullName" TEXT,
    "Country" TEXT,
    CONSTRAINT "car_makers_pkey" PRIMARY KEY ("Id")
);

-- Table: car_names
CREATE TABLE "spider__car_1"."car_names" (
    "MakeId" BIGINT NOT NULL,
    "Model" TEXT,
    "Make" TEXT,
    CONSTRAINT "car_names_pkey" PRIMARY KEY ("MakeId")
);

-- Table: cars_data
CREATE TABLE "spider__car_1"."cars_data" (
    "Id" BIGINT NOT NULL,
    "MPG" TEXT,
    "Cylinders" BIGINT,
    "Edispl" DOUBLE PRECISION,
    "Horsepower" TEXT,
    "Weight" BIGINT,
    "Accelerate" DOUBLE PRECISION,
    "Year" BIGINT,
    CONSTRAINT "cars_data_pkey" PRIMARY KEY ("Id")
);

-- Table: continents
CREATE TABLE "spider__car_1"."continents" (
    "ContId" BIGINT NOT NULL,
    "Continent" TEXT,
    CONSTRAINT "continents_pkey" PRIMARY KEY ("ContId")
);

-- Table: countries
CREATE TABLE "spider__car_1"."countries" (
    "CountryId" BIGINT NOT NULL,
    "CountryName" TEXT,
    "Continent" BIGINT,
    CONSTRAINT "countries_pkey" PRIMARY KEY ("CountryId")
);

-- Table: model_list
CREATE TABLE "spider__car_1"."model_list" (
    "ModelId" BIGINT NOT NULL,
    "Maker" BIGINT,
    "Model" TEXT,
    CONSTRAINT "model_list_pkey" PRIMARY KEY ("ModelId"),
    CONSTRAINT "model_list_Model_key" UNIQUE ("Model")
);

-- Foreign Keys
ALTER TABLE "spider__car_1"."cars_data" ADD CONSTRAINT "fk_cars_data_0" FOREIGN KEY ("Id") REFERENCES "spider__car_1"."car_names" ("MakeId") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "spider__car_1"."countries" ADD CONSTRAINT "fk_countries_0" FOREIGN KEY ("Continent") REFERENCES "spider__car_1"."continents" ("ContId") ON DELETE NO ACTION ON UPDATE NO ACTION;
