mysql json 子表,MySQL JSON存储与两个表

Would there be any benefit in using JSON to store data in a table vs having a separate meta table?

Here is the original schema:

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 would prefer to use it, but how much slower is it than the original version?

In my case, I need the user's avatars (and different sizes) almost every query.

解决方案

Using a big text file to store serialized (no matter what kind of serialization) means :

No need to modify the schema to add / remove columns

Ability to store pretty much anything you want

BUT : you will not be able to work with those data on the MySQL side -- especially, you won't be able to use those in a where clause.

Basically, this means using MySQL to store data -- and nothing more than storage

If you only want to use those data on the PHP side, and never have to work with the on the SQL side, I suppose that storing everything a big text field is a solution.

(and, in this case, I don't see why it would be slower than another solution)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值