1

In this hypothetical example should the foreign key constraint setup for the ProductId and UserId columns in the ProductUserCommentAction table be referencing the Product/User tables as shown in the first diagram OR is it OK for those columns to reference the ProductUserComment table as shown in the second diagram?

I like how it's setup in the second diagram as it reduces the spider web in visualizations.

Are there any downsides to this second approach?

enter image description here

Versus

enter image description here

2
  • Also in the second the key should be (ProductId,UserId,ProductuserCommentActionId). Otherwise you need a seperate index on (ProductId,UserId). – David Browne - Microsoft May 31 '20 at 14:23
  • Does a ProductUserCommentAction record require a ProductUserComment record? If so, how many Action records can be associated with a single Comment record? – HandyD Jun 1 '20 at 5:00
1

I think the 2nd is better. Because I guess you should not allow a ProductUserCommentAction if there is no ProductUserComment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.