table creation scripts:
CREATE TABLE ingredients (_id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, ingredient varchar(50) NOT NULL); //INSERT INTO ingredients(ingredient) VALUES ('salt') //INSERT INTO ingredients(ingredient) VALUES ('chicken')
CREATE TABLE recipes(_id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY, recipe VARCHAR(50), ingredient_id integer, CONSTRAINT fk_ingredient FOREIGN KEY(ingredient_id) REFERENCES ingredients(_id) ON DELETE SET NULL) //INSERT INTO recipes(recipe) VALUES ('baked chicken')
CREATE TABLE requirements (_id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, recipe_id INT, ingredient_id INT, CONSTRAINT fk_recipe FOREIGN KEY(recipe_id) REFERENCES recipes(_id) ON DELETE SET NULL, CONSTRAINT fk_ingredient FOREIGN KEY(ingredient_id) REFERENCES ingredients(_id) ON DELETE SET NULL); //INSERT INTO requirements(recipe_id, ingredient_id) VALUES ('salt')
// elephantsql API info: https://docs.elephantsql.com/elephantsql_api.html
select i._id FROM ingredients i where ingredient = 'salt';