Whatever the best solution, IMHO depends not only on the table, but also on how it is used elsewhere in the application.
Assuming the comments are related to some other object, let's say you retrieve all the comments from that object. In the proposed design, to extract all comments, you need to select only one table, which is effective. But this is extracting comments without extracting poster information for each comment. Perhaps you do not want to show this, or maybe they are already cached in memory.
But what if you needed to get information about the poster when you received comments? Then you need to join two different tables, and now the resulting record set is polluted with a lot of NULL values ​​(for the profile comment, all user fields will be NULL). The code that should analyze this result set can also become more complex.
Personally, I probably start with a fully normalized version, and then denormalize when I start to see performance issues
There is also a completely different possible solution to the problem, but it depends on whether it makes sense in the domain. What if the application has other places where the user and the poster can be used interchangeably? What if the user is just a special kind of profile? Then I think that the solution should be decided mainly in the user / profile tables. For example (some abbreviated pseudo-sql):
create table AbstractProfile (ID primary key, type )
Then any place in your application where a user or profile can be used interchangeably, you can refer to LoginID.
Pete
source share