I'm trying to come up with a database schema which is going to be used for a social network similar to that of Facebook.
Now for posts
I have two schemas in mind which are as follows:
- Single-Table Design
In this approach there will only be a singular table for all post types (text, photo, video, etc.).
The structure could be similar to the following:
|-----------------------------------------------|
| id | user_id | type | content | ... |
|-----------------------------------------------|
The content
column will contain the json_encoded
data for all media types.
- Multi-Table Design
This approach would consider different tables for each media type, which will be one main table that contains the main post record and each media oriented table will contains respective media data.
Posts table:
|-----------------------------------------------|
| id | user_id | type | content | ... |
|-----------------------------------------------|
Photos Table:
|------------------------------------------------------------|
| id | post_id | user_id | url | thumb_url | ... |
|------------------------------------------------------------|
Videos table:
|-----------------------------------------------------------------|
| id | post_id | user_id | url | screenshot_url | ... |
|-----------------------------------------------------------------|
and so on...
I would be delighted if you could guide me of which approach is better or any other schema that would serve the purpose in better condition, performance wise.