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.
| Author |
Topic |
|
krisleech
Starting Member
1 Post |
Posted - 2003-06-06 : 17:57:45
|
| hi all,Can you tell me if this is right .Q). I have two tables one called PersonTBL and one called GroupsTBL, the idea being each Person can be in many Groups. So do i need a third table to create a relationship between the two Tables? ie. a third table called say People_IN_Groups that is just two fields eg. PersonID and GroupID? Each time you wish to relate a person to a group you add a record to the People_IN_Groups table with the PersonID of the person and the GroupID of the Group they are related to.Many thanks Kris. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-06-06 : 18:02:20
|
| Yes that is one way to do it. That is the way that we manage a grouping of users/people here. Don't forget to add foreign keys!Tara |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-06-06 : 18:13:25
|
| You need this type of structure to reflect a many to many relationship.The table in the middle is called a conjoint table, linking table, join table, association table, junction table, ....I call it a conjoint.Keep a consistent naming convention for these tables and the fields in them.People_Groups_Memberships?(Plural table names? yuk!).==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-06-06 : 18:18:04
|
| We've got a conjoint table called Company_Company_Group, which is a grouping of companies. I just hate the name. Tara |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2003-06-06 : 18:50:55
|
| we typically names these with an _xref extension. Maybe your table would be Person_Group_XREF or something like that. Keeps it easy to understand the function of the table.-ec |
 |
|
|
|
|
|