Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
iwannabebobdylan
Jun 10, 2004
I'm wondering what the best tool, or the proper framework, would be for this scenario:

User inputs 4 ingredients that he has in his fridge and the website returns all recipes in a database that feature 3 or 4 of those ingredients.

I keep running into website ideas (and scenarios in life) where databases like this would be helpful. I've started with Wordpress and the tagging system (because it's easy), but that only accounts for 1 match, and it isn't the best at inputting the info. Is there a simple 3 word answer to this that can get me headed in the right direction? Or does this database tool exist?

Adbot
ADBOT LOVES YOU

iwannabebobdylan
Jun 10, 2004

Scaramouche posted:

To do this you'll need a 'real' database. A basic structure would be:
Recipes Table (RecipeID, RecipeName, PreperationTime, etc etc.)
Ingredients Table (IngredientID, IngredientName, etc etc.)
Recipes_Ingredients Table (RI_ID, RecipeID, IngredientID, Amount, etc etc)

Then pull a query like
SELECT * FROM Recipes WHERE RecipeID IN(SELECT DISTINCT RecipeID FROM Reciples_Ingredients WHERE IngredientID IN(1,2,3,4)) -- Assuming 1,2,3,4 were the ingredients specified

The SQL isn't optimized but you get the idea

Hey thanks! This is great stuff.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply