Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Anyone?

Last updated 2 years ago.
0

Not sure I fully understand what you're after (or how things are stored tbh) but I don't think having N template tables is a good idea. All these tables share the same structure so they can be merged. Just add an extra "type" column, which values would be 1, 2, 3 etc, and off you go.

It should then be easier to join template and content tables and make use of eager loading.

Last updated 2 years ago.
0

JoolsMcFly said:

Not sure I fully understand what you're after (or how things are stored tbh) but I don't think having N template tables is a good idea. All these tables share the same structure so they can be merged. Just add an extra "type" column, which values would be 1, 2, 3 etc, and off you go.

It should then be easier to join template and content tables and make use of eager loading.

Well no they do not share the same structure, but some columns do (in this case). Thats why I placed three 'dots' on the end, meaning there are more columns. Some template might only have those 3 columns (id, page_title, menu_title) but my other templates might have 10 more columns.

Using one table to hold all the templates when I only use 3 columns (of that table) and leaving the other columns empty is in my opinion bad practice.

What I am after is a efficient way of retrieving my data. Because so far I only managed to retrieve the data using a foreach which resulted in +80 queries (depending on the amount of pages ofcourse).

Last updated 2 years ago.
0

You could store additional params in an "extra" column in JSON format if you don't need to use them in queries.

Last updated 2 years ago.
0

If you could show me an example, that would be great. So far, I don't see how putting the extra data as JSON in a column would solve my problem. I would still get a high amount of queries and wont be able to use a Query condition if that data is in the JSON.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

sestolk sestolk Joined 17 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.