Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Dealing With Many To Many Relationships


Dealing With Many To Many Relationships

Author
Message
joshdbguy
joshdbguy
Old Hand
Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)

Group: General Forum Members
Points: 313 Visits: 725
Here's an example of something I'm trying to deal with. There are two sets of data that are unique. Let's say Table 1 consists of Clients. Let's say table 2 consists of Online Services. Both of these are unique. One client can have multiple online services while one online service can have multiple clients. What's the best way to relate these tables? I was thinking of creating a relationship table with unique values so that each table would have a one to many relationship to the relationship table.
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16568 Visits: 17016
JoshDBGuy (3/26/2014)
Here's an example of something I'm trying to deal with. There are two sets of data that are unique. Let's say Table 1 consists of Clients. Let's say table 2 consists of Online Services. Both of these are unique. One client can have multiple online services while one online service can have multiple clients. What's the best way to relate these tables? I was thinking of creating a relationship table with unique values so that each table would have a one to many relationship to the relationship table.


Yes that is the best way to deal with this. Create a table like ClientServices. All it needs is the primary key from Clients and the primary key from OnlineServices.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
joshdbguy
joshdbguy
Old Hand
Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)Old Hand (313 reputation)

Group: General Forum Members
Points: 313 Visits: 725
Thanks Sean.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search