https://github.com/ryangrieb/recipedatabase
Small project that generates a recipe database given a YML file.
https://github.com/ryangrieb/recipedatabase
Last synced: 6 months ago
JSON representation
Small project that generates a recipe database given a YML file.
- Host: GitHub
- URL: https://github.com/ryangrieb/recipedatabase
- Owner: RyanGrieb
- Created: 2023-12-01T22:27:49.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-02T19:56:24.000Z (about 2 years ago)
- Last Synced: 2025-03-02T09:44:54.690Z (11 months ago)
- Language: Python
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
_Intro to Database Systems - Project Phase 3_
_Project Name: Recipe Database – Explore recipes using ingredients._
## Objective:
1. Generate a SQL Database, and insert all recipes found inside our .yml file.
2. Modify the Database such that we can `SELECT` recipes based on `ingredient_name`(s)
### Generate database
1. Install docker
2. Navigate to the projects current working directory, and enter: `docker compose up -d`
3. To view generated data, see the instructions below.
---
### To enter our database inside the container:
1. Find container_id of db container with `docker ps`
2. Enter container with `docker exec -it bash`
3. Enter into the PostgreSQL command line `psql -U user -d mydatabase`
### To generate the database .sql file:
1. Find container_id of db container with `docker ps`
2. Generate the .sql file with `docker exec -it pg_dump -U user -d mydatabase > mydatabase.sql`
### To select a recipe that uses an ingredient:
`
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';`
### Example - Select all recipes containing 'Onions':
`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';`