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

aurelianspodarec's avatar

What do you guys think of this data structure?

Hi there!

What do you guys think of this data structure? https://i.imgur.com/KAbWsib.png

The way it should work, is: Anything connected to the company, should be able to get company value. So Company Pages should be able to be filtered by brand_colors and also display the brand color of the parent company - same with company components.

Company will be displayed on a page, as well as pages and components will have their own page which will be able to be filtered. Only one company page content will be shown. So if we fetch company pages that will call one company pages content which is either mobile true/false and dark true/false - and this will change based on what the user filters.

Now, there is a pages table as well - which has ALL of the company fields, pages and it should act like the company, however, its not a company, its just an individual page.

So pages and company pages would be joined, display the exact same data, and also should be filtered together.

What do you guys think of this data structure?

I feel like, something could be improved.

0 likes
3 replies
Snapey's avatar

I don't see the reason for the complication of having the same data in two places. That just leads to an additional maintenance overhead

1 like
aurelianspodarec's avatar

@Snapey You're reffering to company and pages right.

The thing is that if I put an individual page, then its no longer a company so the semantics are wrong. So then in the company table I would ass is_company for the user to filter just companies or all - but on the company pagge, I would never show windividual pages either, so them being in the company table seems wrong.

Not sure.

Also, if I want to display brand color inside company pages ther's no way to do it without writing manual SQL or using a package like this https://github.com/staudenmeir/belongs-to-through - which makes me think if I did something wrong in general structuring this

aurelianspodarec's avatar

Thinking more about it...

Maybe havig something like posts instead of companies, and then have a category company, person, 'individual page`.

So that way it will be easier to maintain like Snapey said, and that seems the only way. So it feels like that must be all in one table in that case, the table company needs a different name.

And if not companies what would you name this? It will include: companies, people(personal site of a person) and some random page/individual page.

Please or to participate in this conversation.