I want to know which one structure is good to store about 50 data in same time into MySQL?
First
data_id user_id data_key data_content
---------------------------------------------------
1 2 data_key1 content 1
2 2 data_key2 content 2
3 2 data_key3 content 3
.. .. .. ..
.. .. .. ..
50 2 data_key50 content 50
Seconds
data_id user_id data_key1 data_key2 data_key3 .. .. data_key50
-------------------------------------------------------------------
1 2 content 1 content 2 content 3 .. .. content 50
Or have other solution? user_id will have more than 5000 users.
Do you know the data keys before hand and are they likely to change? If they’re along the lines of “first_name, last_name, hair_color, eye_color, birthday, …” then the second model would be feasible since you’ll often want to retrieve all of these for a user at the same time.
The first model is like having a persistent hashtable, so you’d have to store all the values as strings, and your app will have to know which keys to query for. This can make sense if the keys are user defined, however.