Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Storing data related question

Author  Topic 

gggg
Starting Member

1 Post

Posted - 2009-07-23 : 10:46:07
I have a table called recipe which has one record per recipe. A recipe can belong to multiple recipe categories e.g. main course, season. In a given recipe record, I want to store both the values main course and season in recipe category field for a given recipe record. My questions are as follows:

(a) I need to create this data in excel so that it can be loaded in SQL Server database. How do I store multiple values for recipe category field in Excel for a given recipe record so that it can be loaded as one recipe record in SQL Server?
(b) How should these mutliple values for recipe category field in SQL Server record be stored for a given recipe record so that appropriate queries can be run against this table?

Will appreciate any help regarding this. Thanks.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-23 : 11:46:29
Don't do anything like that!
It is a one to many relation and so you need to tables.

table recipe
id
other_recipe_info_column

table recipe_category
id
recipe_id
other_recipe_category_info_column

Each entry in table recipe_category has a relation to exactly one entry in table recipe via recipe_id



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -