Dealing With Many To Many Relationships

  • 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.

  • 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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Thanks Sean.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply