Skip to main content

JSON DB Fields: Yay or Nay?

Premium
6:45

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 09 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

A
Ace ✓ Link copied!

Hi, I need to make some decisions as to the DB structure. I am using filament and spatie translations and other plugins that use the json column. I have a headless Laravel API for mobile and web.

I have a DB with many tables/models and pivot tables between them. My app needs to be ready for multi-lingual for example a recipe table with: title, description. recipe steps table with text instructions per step. the question is will using spatie translate for these fields compromise the query performance to much when doing text search queries?? For example search: "Pork Belly" in the recipe title and description.

If everyone is using it maybe it's working fine. I didn't find info about performance issues in real life production examples. thanks

IS
Ilya Savianok ✓ Link copied!

What do you think about using JSON format for storing array of images related to the exact entry?

M
Modestas ✓ Link copied!

It's possible, but not great.

For example, if you need to search what file belongs to what user - that would get complicated. You would have to search JSON arrays and it's slower to do so.

But other than slowness and potential issues at a later day (or even coding challenges) - you should be okay. I would still prefer a new table with Model, but JSON is okay.

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.