0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

データベースのカラムにjsonデータを保存する時のメリットとデメリット

Last updated at Posted at 2021-06-14

データベースのカラムにjsonデータを保存する時の注意点などを覚書。

メリット

 ・サブテーブルのデータをjsonとして保存しておけば、テーブル連結が不要になるので、検索が速くなる。

デメリット

 ・jsonデータの中身をWHERE句などで条件設定したりすることは出来ない。
  出来ないことは無いかもしれないが、相当ややこしい。

まとめ

jsonデータを使用する場合は、あくまで操作する必要のないものに限定し、WHERE句などで条件設定するデータは、jsonには向かない。
素直にテーブル連結した方が良い。

追記

 一応、JSON関数という便利なものもあるようですね。まだ、使用したことは無いのですが、WHERE句などにも使用できるのかな?
MySQLでJSONを扱う
JSON Functions

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?