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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Referencing Sub-Category and Category through ID

Author  Topic 

Crazy88s
Starting Member

2 Posts

Posted - 2008-02-13 : 09:31:32
I have the following table layout:



As you can see I have a couple of many to many relationship tables in the picture above. Programs can have many Meal Categories and a Meal Category can belong to many Programs. Likewise is the case with Meal Categories and Meal Types. Meal Categories can have many Meal Types and Meal Types can belong to many Meal Categories.

The problem is with the Meal Order Items table. I'm storing The Meal Order ID along with the Meal Type ID and the Quantity. I want to be able to reference the Meal Category and Program using the Meal Type ID but due to the many to many relationships, this can lead to multiple names.

Do I need to store the Program ID and Meal Category ID in my Meal Order Items table or is there a method I'm missing here?

Thanks for your assistance!

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-02-13 : 11:27:59
In terms of multiple names , you can use aliases, but looking at your main problem , could you tell me if a meal order has a one to one with programs

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

Crazy88s
Starting Member

2 Posts

Posted - 2008-02-13 : 12:35:56
No. Meal Order does not have a one to one with the Program table. It doesn't need to. Meal Order only has a relationship with Meal Order Items and the Client table (not shown in the picture).

I'm thinking I'll have to store the MealCategoryID and ProgramID in the Meal Order Items table. That doesn't seem ideal though.



Go to Top of Page
   

- Advertisement -