0

i have a question. please suppose that we have different entities like category,blog,videos,... and each of them has own comments. how can i use one comment table for all of these entities just using one FK?is that TPH pattern?how can i implement it in codefirst approach? something like this Comments(CommentID, ..., PostID, VideoID) to Comments(CommentID). thanks in advance.

1 Answers1

0

You can eliminate the FK from the comments table by using Many-to-Many relationships or separate linking entities for the relationships.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
  • i dont want to have fk for every table because there are several null values for fk consider that we have 100 records of category in comments table rest of the fk like video or blog will be null in all 100 records.i just want to have one fk for all tables and using something like discriminator to identify which comment is for which table – reza setareh Nov 11 '21 at 20:34