What would be a better database design for a social network website? A single table with more columns and fewer rows, or multiple tables with fewer columns but more rows?
For example: A user can post an update on their wall or in a group.
Two database designs I can think of are:
Design 1
UserPosts
- id
- userId
- post
- datetime
UserGroupPost:
- id
- groupId
- userId
- post
- datetime
Potential problem : Might require joins, which can (in future) be a slow query.
Design 2
Posts:
- id
- userId
- groupId
- post
- datetime (where groupid would be null if user posts on their wall)
Potential Problem : Looping over large dataset could take a (long)time.
How can I get better performance when data increases? Is there any other (better) way?