Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

traceyjas's avatar

Array data column vs creating a next table

When do you recommend using an array or json column vs creating a next table and creating a relationship?

0 likes
2 replies
koramit's avatar

JSON column give you a flexibility to adapt your app when there are many change requests so, you no need to touch database layer.

But when your reach amount of records, let says 50k rows. It became slow when you run search or analytics query on json field.

Of cause some database engine like MySQL allow you to build index of json key but this bring you to database layer.

One of my app heavily use json field because a lot of CRs. It work fine because a regular task is done with id for query and I would go to transform data structure to a separate database for analytics.

It's depends on the requirement. I think strict with simple datatype whenever you can it very easy to tune db performance. But if you not search on json field too much, it very handy.

Hope this help.

traceyjas's avatar

I don't really plan or foresee any of searching on those fields

Please or to participate in this conversation.