Intro to Database Systems - Project Phase 3
Project Name: Recipe Database – Explore recipes using ingredients.
- Generate a SQL Database, and insert all recipes found inside our .yml file.
- Modify the Database such that we can
SELECT
recipes based oningredient_name
(s)
- Install docker
- Navigate to the projects current working directory, and enter:
docker compose up -d
- To view generated data, see the instructions below.
- Find container_id of db container with
docker ps
- Enter container with
docker exec -it <container_id> bash
- Enter into the PostgreSQL command line
psql -U user -d mydatabase
- Find container_id of db container with
docker ps
- Generate the .sql file with
docker exec -it <container_id> pg_dump -U user -d mydatabase > mydatabase.sql
SELECT recipe.recipe_id, recipe.recipe_name FROM recipe JOIN quantity ON recipe.recipe_id = quantity.recipe_id JOIN ingredient ON quantity.ingredient_id = ingredient.ingredient_id WHERE ingredient.ingredient_name = 'INGREDIENT_NAME';
SELECT recipe.recipe_id, recipe.recipe_name FROM recipe JOIN quantity ON recipe.recipe_id = quantity.recipe_id JOIN ingredient ON quantity.ingredient_id = ingredient.ingredient_id WHERE ingredient.ingredient_name = 'Onion';