CREATE TABLE "Lot" (
  "LotNumber" SERIAL PRIMARY KEY,
  "CreateDate" date,
  "Cost_Of_Materials" float
);

CREATE TABLE "Lot_Raw_Materials" (
  "id" SERIAL PRIMARY KEY
);

CREATE TABLE "Raw_Materials" (
  "material_id" SERIAL PRIMARY KEY,
  "UniCost" float,
  "type" varchar
);

CREATE TABLE "Production_Units" (
  "serial" SERIAL PRIMARY KEY,
  "exactWeight" float,
  "ProductType" varchar,
  "ProductDesc" float
);

ALTER TABLE "Lot" ADD FOREIGN KEY ("LotNumber") REFERENCES "Lot_Raw_Materials" ("id");

ALTER TABLE "Raw_Materials" ADD FOREIGN KEY ("material_id") REFERENCES "Lot_Raw_Materials" ("id");

ALTER TABLE "Production_Units" ADD FOREIGN KEY ("serial") REFERENCES "Lot" ("LotNumber");
