Sample Header Ad - 728x90

M:M Table Design - Use of PK

0 votes
1 answer
67 views
I have a many-to-many table that contains id's from 2 related tables. For creating a primary key on this table, is it better to create another integer column and have that as a surrogate PK? Or should I create the PK on both id columns? What are the benefits of either method? Here is the table design with the surrogate key (CodeGroupMappingID) CREATE TABLE [dbo].[CodeGroupMappings]( [CodeGroupMappingID] [int] IDENTITY(1,1) NOT NULL, [CodeID] [int] NOT NULL, [GroupID] [int] NOT NULL, CONSTRAINT [PK_CodeGroupMappings_CodeGroupMappingID] PRIMARY KEY CLUSTERED ([CodeGroupMappingID] ASC) )
Asked by Kevin (533 rep)
May 22, 2018, 09:41 AM
Last activity: May 22, 2018, 08:51 PM