View Single Post

  #5 (permalink)  
Old 04-17-2006
Sjoerd
 
Posts: n/a
Default Re: seperator instead of a comma for listed items in DB?


news@celticbear.com wrote:
> need to have DB fields in mySQL that
> will have lists of values


Typically, one would use escape characters. For example, | would be
used to seperate two fields. A literal | would be escaped: \|. This
makes it possible to use the seperation character in the data.

Another, probably better option, would be to make a seperate table.
Instead of storing the ingredients seperated by a character like this:
1, Chinese Chicken, chicken|salt|pepper|mushrooms
Think about making a ingredients table and storing it there:

[Recipes]
1, Chinese Chicken
2, Meatloaf

[Ingredients]
1, chicken
1, salt
1, pepper
1, mushrooms
2, meat
2, loaf

This makes it easy to search and it is more logical from a DB point of
view.

Reply With Quote