I currently have two joined tables in a SQL Server database, one with news items (newsTab) and a table (usrCom) which captures multiple user comments for each article.
I want to add another information table (infoTab) which will also allow users to comment but I wish to use the existing comments table (usrCom) to store these.
How do I go about creating a linking/bridge table which generates a unique ID so I know which table (newsTab/infoTab) the comments belong to.
NB: I’ve edited the message to hopefully make it a bit clearer
First Table (newsTab)
NewsId NewsContent
---------------------
1 blah blah
2 and so on
Second Table (infoTab)
infoId InfoContent
---------------------
1 some info
2 more stuff
Comments Table (as is currently)
commentId linksTo Comment
------------------------------
1 1 user input
2 1 random rant
‘linksTo’ is a foriegn key to the items in the first table, so I cannot just add a type column and I would get conflicts on the foreign key column if a row did not exist in the new table with the same ID. So hence the need for a new generated foreign key based upon the table and Id that was being commented on.
Why not just a “type” column to the usrCom