Which is best practice?
Scenario: If I have 2 tables, one called topics
and another called posts
whereby each post belongs to a specific topic_id
.
Would it be best to have a column in the topics
table called post_count
which I would update whenever a post is created/delete under that topic_id
.
Or would it be best to count the number of rows where a topic_id
matches using a SELECT COUNT query?
Are there any disadvantages to either or differences in efficiency?