MySQL JSON Storage vs. Two Tables

Will there be any benefit from using JSON to store data in a table and have a separate meta table?

Here is the source diagram:

Users Table      UserId  |  Username  |  Etc...
                 5       |  John      |

Avatar Table     Id      |  UserId    |  ImageName         |  ImageType
                 1       |  5         |  example.png       |  original
                 2       |  5         |  example_thumb.png |  thumbnail

Here is the JSON version:

Users Table      UserId  |  Username  |  Avatar
                 5       |  John      |  {"original":"example.png","thumbnail":"example_thumb.png"}

I personally like the json version and prefer to use it, but how much slower than the original version?

In my case, I need custom avatars (and different sizes) for almost every request.

+3
source share
4 answers

Using a large text file to store serialized (regardless of the type of serialization) means:

  • No need to change the layout for adding / removing columns.
  • The ability to store almost anything.
  • : MySQL - , where. , MySQL - ,

PHP SQL-, , .
( , , )

+5

... , ?

, .

MySQL , PM . :

Users    UserID  | UserName  |  Avatar  |  Avatar_Thumb

, . , 30 .

+2

.

: , , ,

,

566.png 566_thumb.png,

+2

- mongoDB JSON. . , mysql.

0

All Articles