dtziv24262 2015-09-25 11:42
浏览 139

MySQL性能 - JSON vs Joins

Lets say, I have at the moment, the following tables:

categories

  • id
  • name (for example "museum", "tower" or "theater")
  • some other fields...

countries

  • id
  • name
  • some other fields...

cities

  • id
  • name
  • country_id
  • some other fields...

sights

  • id
  • name
  • city_id
  • category_id
  • some other fields...

My question / problem

Now I want to combine all these table into a single table which I call "objects". Since the different tables avove haven't the same "some other fields.."-Fields, I need a flexible way of storing this data. There are 2 options:

  • Storing it as a json-string in a field called "data" in the object-table
  • Or storing it in a separete table "properties" (object_id, field_name, field_value)

My Questions:

  • But which version would be better/has a better performace? "Json to Object conversion in PHP and string-search" vs "multiple joins"?
  • For the second version: Which datatype should the field "field_value" have? This value can be filled with anything. From a boolean value to strings.
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题