Entidad_Relacion.sql 697 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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");