Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
vbArch
Starting Member
5 Posts |
Posted - 2011-04-18 : 14:36:39
|
Using SQL Server 2005I want to make a comments table, that consists of a level and the identity value from any table that wants to store a comment. So the Comments table would have three fields a link field that tells me what table to link it to, and the primary key of the record that is associated to it and of course the comment iteself. Now here's the problem, I need to support this through merge replication. The problem is that that I need a way to create referential integrity between the primary tables and the comments table without creating a comments table for each primary type.These are things that I have tried and can't seem to get to work, using a view to map referential integrity throughalso tried using a synoynm. I am about to try a trigger which I am pretty sure will work, but before I do I would love to know if there is a cleaner solution.Thanks in advance |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-18 : 16:42:08
|
You might consider a conjoint table(sourcetbl, sourcepk, seq, commentID)(commentID, comment)That would mean that you could save space for the same comment applied to multiple rows.For referential integrity you would need the table name or id on the source table or as you say to use triggers. Unfortunately sql server is fairly limited in it's referential integrity implementation.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
akonmask
5 Posts |
Posted - 2011-05-13 : 17:36:29
|
The requiring to the create a table as "Comments", In every has a primary key for each comment. The table would have a foreign key linking back to each "content" table. To many relationship between your content and comments is the An inner join SQL query could get all of the comments for a single content entry. |
|
|
denis_the_thief
Aged Yak Warrior
596 Posts |
Posted - 2011-05-19 : 15:27:06
|
Here are a few ideas:1. Make a separate column for each table. Unfortunatley you'll need several columns but at least this will still be 1 table.2. Put the Foreign Key in the other tables and have that reference your Comment table. You could use a composite key (Table, CommentID). |
|
|
|
|
|