Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.74 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. GOAL:
  2.  
  3. To create a database of liquor in your liquor cabinet, and a database of possible drinks to make.
  4.  
  5. Output:
  6. (1) a list of drinks you can make with your existing liquors, (hard!) and
  7. (2) a list of drinks you could make if you just bought a few more things
  8.  
  9. ===
  10.  
  11. Views that currently exist on the DB: https://gist.github.com/1128805
  12. (the "view_recipes_in_cabinet_using_all_ingredients" isn't quite right - it only matches a recipe that has YOUR ENTIRE cabinet in it, not a non-exclusive subset)
  13.  
  14. Data setup:
  15.  
  16. table users -- The user database
  17. users.identity = unique ID
  18.  
  19. table liquors -- A generic list of alcohol
  20. liquors.id = unique ID
  21. liquors.name = plaintext name
  22.  
  23. table liquorCabinet -- This is "your stockpile of liquor" as a user
  24. liquorCabinet.userID = users.identity
  25. liquorCabinet.liquorID = liquors.id
  26.  
  27. table recipes -- A list of possible recipe (drink) names
  28. recipes.id = unique ID
  29. recipes.name = plaintext name
  30.  
  31. table recipeIngredients -- The list of recipes
  32. recipeIngredients.recipeID = recipes.id
  33. recipeIngredients.liquorID = liquors.id
  34.  
  35. ====
  36.  
  37. Some sample data:
  38.  
  39. A single user (users.identity = 1) has two things in his liquor cabinet:
  40. liquorCabinet.userID = 1 liquorCabinet.liquorID = 1
  41. liquorCabinet.userID = 1 liquorCabinet.liquorID = 2
  42.  
  43. that corresponds to
  44. liquors.id = 1 liquors.name = Vodka
  45. liquors.id = 2 liquors.name = Tequila
  46.  
  47. There are two recipes in the system:
  48. recipes.id = 1 recipes.name = Shot o' Vodka
  49. recipes.id = 2 recipes.name = Gross Mix
  50.  
  51. Which correspond to:
  52. recipeIngredients.recipeID = 1 recipeIngredients.liquorID = 1
  53. recipeIngredients.recipeID = 2 recipeIngredients.liquorID = 1
  54. recipeIngredients.recipeID = 2 recipeIngredients.liquorID = 2
  55.  
  56. As it stands, this user can build both recipes as he has all of the necessary required liquors.