- Feb 13, 2003
- 26,256
- 406
- 126
I'm sure someone will be able to answer this pretty easily but it's just something I've been wondering about.
I have three tables: A "Post" table, a "Tag" table, and a "PostTag" table. The "Post" table has an auto-increment "ID" column and a few other unimportant columns. The "Tag" table has an auto-increment "ID" column and an unimportant nvarchar column.
The question I have is regarding the "PostTag" table. This table is a connecting table between "Post" and "Tag": a record in "Post" can have multiple Tags, so "PostTag" has two columns; one to store "Post.ID" and one to store "Tag.ID". The question is: do you recommend I make a composite primary key from these two columns, or should I add another column, "ID", that is auto-increment, and make that the primary key?
If it matters, I'm using SQL Server 2008 and .NET 4.0, and I will be using LINQ-to-SQL for data access. Thanks for any input!
I have three tables: A "Post" table, a "Tag" table, and a "PostTag" table. The "Post" table has an auto-increment "ID" column and a few other unimportant columns. The "Tag" table has an auto-increment "ID" column and an unimportant nvarchar column.
The question I have is regarding the "PostTag" table. This table is a connecting table between "Post" and "Tag": a record in "Post" can have multiple Tags, so "PostTag" has two columns; one to store "Post.ID" and one to store "Tag.ID". The question is: do you recommend I make a composite primary key from these two columns, or should I add another column, "ID", that is auto-increment, and make that the primary key?
If it matters, I'm using SQL Server 2008 and .NET 4.0, and I will be using LINQ-to-SQL for data access. Thanks for any input!
