Created
November 7, 2019 23:12
-
-
Save just-Bri/411c2168cef7ca0362a7f89ee3da373e to your computer and use it in GitHub Desktop.
sql stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS recipe_reqs; | |
DROP TABLE IF EXISTS recipes; | |
DROP TABLE IF EXISTS ingredients; | |
DROP TABLE IF EXISTS hardware; | |
DROP TABLE IF EXISTS instructions; | |
CREATE TABLE "ingredients" ( | |
"id" int NOT NULL GENERATED ALWAYS AS IDENTITY, | |
"name" varchar(50) NOT NULL, | |
PRIMARY KEY(id) | |
); | |
CREATE TABLE "hardware" ( | |
"id" int NOT NULL GENERATED ALWAYS AS IDENTITY, | |
"name" varchar(50) NOT NULL, | |
PRIMARY KEY(id) | |
); | |
CREATE TABLE "instructions" ( | |
"id" int NOT NULL GENERATED ALWAYS AS IDENTITY, | |
"recipe_id" int NOT NULL, | |
"step_number" int NOT NULL, | |
"instruction" varchar(500) NOT NULL | |
); | |
CREATE TABLE "recipes" ( | |
"id" int NOT NULL GENERATED ALWAYS AS IDENTITY, | |
"name" varchar(50) NOT NULL, | |
"category" varchar(20) NOT NULL, | |
"image_url" varchar(2083), | |
"prep_time" int NOT NULL, | |
"cook_time" int NOT NULL, | |
PRIMARY KEY(id) | |
); | |
CREATE TABLE "recipe_reqs" ( | |
"recipe_id" int NOT NULL, | |
"hardware_id" int, | |
"ingredient_id" int, | |
"ingredient_amount" VARCHAR(50), | |
"instruction_id" int, | |
PRIMARY KEY(recipe_id), | |
CONSTRAINT "FK_50" FOREIGN KEY ("recipe_id") REFERENCES "recipes" ("id"), | |
CONSTRAINT "FK_53" FOREIGN KEY ("hardware_id") REFERENCES "hardware" ("id"), | |
CONSTRAINT "FK_56" FOREIGN KEY ("ingredient_id") REFERENCES "ingredients" ("id"), | |
CONSTRAINT "FK_59" FOREIGN KEY ("instruction_id") REFERENCES "instructions" ("id") | |
); | |
CREATE UNIQUE INDEX "PK_ingredients" ON "ingredients" ("id"); | |
CREATE UNIQUE INDEX "PK_instructions" ON "instructions" ("id"); | |
CREATE UNIQUE INDEX "PK_hardware" ON "hardware" ("id"); | |
CREATE UNIQUE INDEX "PK_recipes" ON "recipes" ("id"); | |
CREATE UNIQUE INDEX "PK_instructions" ON "instructions" ("id"); | |
CREATE INDEX "fkIdx_50" ON "recipe_reqs" ("recipe_id"); | |
CREATE INDEX "fkIdx_53" ON "recipe_reqs" ("hardware_id"); | |
CREATE INDEX "fkIdx_56" ON "recipe_reqs" ("ingredient_id"); | |
CREATE INDEX "fkIdx_59" ON "recipe_reqs" ("instruction_id"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment