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

-- Table: device
CREATE TABLE "spider__device"."device" (
    "Device_ID" BIGINT NOT NULL,
    "Device" TEXT,
    "Carrier" TEXT,
    "Package_Version" TEXT,
    "Applications" TEXT,
    "Software_Platform" TEXT,
    CONSTRAINT "device_pkey" PRIMARY KEY ("Device_ID")
);

-- Table: shop
CREATE TABLE "spider__device"."shop" (
    "Shop_ID" BIGINT NOT NULL,
    "Shop_Name" TEXT,
    "Location" TEXT,
    "Open_Date" TEXT,
    "Open_Year" BIGINT,
    CONSTRAINT "shop_pkey" PRIMARY KEY ("Shop_ID")
);

-- Table: stock
CREATE TABLE "spider__device"."stock" (
    "Shop_ID" BIGINT NOT NULL,
    "Device_ID" BIGINT NOT NULL,
    "Quantity" BIGINT,
    CONSTRAINT "stock_pkey" PRIMARY KEY ("Shop_ID", "Device_ID")
);

-- Foreign Keys
ALTER TABLE "spider__device"."stock" ADD CONSTRAINT "fk_stock_0" FOREIGN KEY ("Device_ID") REFERENCES "spider__device"."device" ("Device_ID") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "spider__device"."stock" ADD CONSTRAINT "fk_stock_1" FOREIGN KEY ("Shop_ID") REFERENCES "spider__device"."shop" ("Shop_ID") ON DELETE NO ACTION ON UPDATE NO ACTION;
