Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-structure ingredients to be more robust #172

Open
2 tasks
dpopp07 opened this issue Jun 22, 2018 · 1 comment
Open
2 tasks

Re-structure ingredients to be more robust #172

dpopp07 opened this issue Jun 22, 2018 · 1 comment
Assignees
Labels

Comments

@dpopp07
Copy link
Collaborator

dpopp07 commented Jun 22, 2018

From James:

Ideas for future-proofing our data:

Ingredients as objects instead of strings (and their own table)
    Own table b/c a lot of drinks might have the same ingredient
    Object b/c maybe we care about some other stuff like
        subsitutes
        image url
    Object because maybe we want stuff like optional to be a boolean flag
    Object because then we can use unique IDs (altho we could do this w/ strings rn) to allow for things like sorting by ingredient, filtering by ingredient, "look up what drinks you can make based on ingredients you have"

Acceptance Criteria:

  • Structure of an Ingredient defined
  • Functionality defined for adding a drink, validating the drink object against the ingredients database
@dpopp07 dpopp07 added the db label Jun 22, 2018
@jamesvclements jamesvclements changed the title Re-strucutre ingredients to be more robust Re-structure ingredients to be more robust Jul 11, 2018
@dpopp07 dpopp07 self-assigned this Jul 30, 2018
@dpopp07
Copy link
Collaborator Author

dpopp07 commented Aug 10, 2018

I've been thinking about this and I have a proposal. I don't want to have to use pointers to another table from within the Drinks table because that would require a DB lookup for every ingredient (best case, assuming we're caching, which we're not right now). NoSQL best practice recommends using as few tables/joins as possible. That said, I appreciate the need for consistency across ingredients for filtering, etc.

So! My proposal is - have an Ingredients table the master blueprints of every ingredient. When a drink is created, all ingredient objects are validated against this table but the Drinks table just contains the raw, nested objects. These can even include the unique IDs assigned by Rethink, pulled from the Ingredients table at drink creation time. Drinks will be created far less often than all the drinks will be queried so I think this is more efficient. Even updating an Ingredient would be a simple operation to update all the drinks containing that ingredient if they have IDs attached to them

Let me know what you think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant