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 2000 Forums
 SQL Server Development (2000)
 Many to many relationship - add/delete

Author  Topic 

purell
Starting Member

17 Posts

Posted - 2006-08-03 : 22:48:12
I have a many to many relationship

I can design the table 2 ways:

1) Category table (cat_id, cat_name, active) - cat_id as PK
CategoryReq (cat_id, req_name) - cat_id & req_name as PK

2)
CategoryReq (req_name, cat_name) - req_name & cat_name as PK

If I design 1st way. Then when they want to add and delete from the CategoryRequest table, they would have to add to the category table first. Then maybe build a list of checkboxes to select from. The one's they check insert into the CategoryRequest table.

Drawback of this is that they can't edit the list on the fly. Since it may be used by other request (since cat_id CategoryReq is fk into Category table)

If I design it the 2nd way. Then they can edit, delete, add on the fly. But there won't be a master category list.

Which way is better? I will do it in .NET

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2006-08-04 : 00:39:08
If I'm following you correctly, users will be able to add new catagories, and for each catagory they can add requests. This should be done with 2 tables. I am not sure I am following the part about;

"Drawback of this is that they can't edit the list on the fly. Since it may be used by other request (since cat_id CategoryReq is fk into Category table)"

Can you please explain your application, and how this conflict might arise.
Go to Top of Page

purell
Starting Member

17 Posts

Posted - 2006-08-04 : 11:29:11
First users will pick a request. Then for that request they can pick many categories. (a list of categories - as a checkbox field i'm assuming)

Problem is how do I have them edit the category from the list.

So if I pick request1, then see 10 categories. Then click edit to edit category1 - it will edit the category in the category table.

That category might be used by other requests. So if you change it for that one request, it will affect any other request.
Go to Top of Page
   

- Advertisement -