|
Posted by JDS on 09/28/27 11:45
On Mon, 17 Apr 2006 12:09:24 -0700, news@celticbear.com wrote:
> Then the tbl_recipes would have colums like:
> ID, NAME, INGREDIENTS, MEASUREMENTS, NOTES
> with data like:
> 1, Chinese Chicken, 1|2|3|4, 1 clove|1 lbs. breast| 1 tsp.| 1 T., more
> stuff here....
You *could* do that but typically a reational database will use *another*
table to "link" the one-to-many relationship together.
table 1: ingredients
table 2: recipe
table 3: recipe-to-ingredients-linker
Table 1 and 2 would be as you described but table 3 would be (roughly) as
follows:
create table recipe_ingredients (
id int()
recipe_id int()
ingredient_id int()
... additional_columns ...
)
You then would join all three tables using recipe_id to join recipes to
the linker and then using ingredient_id to join to the ingredients.
This way, you can have an unlimited number of ingredients.
It is clunky from a *human* point of view but fast, flexible, scalable,
etc. from a machine point of view.
(The additional_columns could be things like "quantity" or other modifiers)
later...
--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
Navigation:
[Reply to this message]
|