Additional table vs JSONized data? In my DB structure there are some tables what are sliced into two. In the first table there are the main data and in the other is the additional data. For example:
channel_head
| id | name | driver | created_at | updated_at | deleted_at|
| 1 | Channel1 | Facebook | today | today | NULl |
| 2 | Channel2 | Telegram | today | today | NULL |
channel_data
| id | channel_id | data_type | data |
| 1 | 1 | FACEBOOK_TOKEN | lysjknvlsjnf... |
| 2 | 1 | FACEBOOK_RECIPIENT_ID | 0123456789 |
| 3 | 2 | TELEGRAM_SLUG | channel2 |
| 4 | 2 | TELEGRAM_API_KEY | kefsmsékmfsekfm.... |
My question: what would be wiser?
Place a column next to the driver in channel_head and save a JSONized array in it with the data or leave it as is?
Why do I feel like I've answered this question before?
Is the extra data going to be queried directly or do you want to just retrieve it when you load a channel?
If you want to be able to query the extra data easily, keep it as an extra table.
If you just want the data to be there when you retrieve a channel, make it a JSON field.
Please sign in or create an account to participate in this conversation.