I am building a recipe / food related app for a client. I need a recipe record to point to the ingredient records it depends on, but it also needs to have a mapping of measurements to ingredients.
I think I capture the essence of what I am trying to accomplish adequately in this JSON:
i.imgurDOTcom/42UZhlj.png
{
id: 'bowl-of-cereal',
name: 'Bowl of Cereal',
ingredients: [
// links to records in the Ingredients table.
'milk',
'cereal'
],
measurements: {
{
quantity: 6,
measurement: 'cups',
ingredient: 'cereal',
note: '(not stale)'
},
{
quantity: 16,
measurement: 'ounces',
ingredient: 'milk',
note: '(whole or skim)'
}
},
directions: [ /* ... */ ]
// etc...
}
I believe what I need to do is create a table for measurements with this^ measurement structure enforced. Is this correct or is there an alternative?