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

thomasrstegelmann's avatar

How to approach this mighty multiple taxonomy relationship model

So,

I was trying for a day reading through tips and tricks when dealing with a threeway pivot tables, however I have the feeling I'm missing a fundamental flaw in my thinking and I'm now failing to see the bigger picture after fighting this.

Problem The user access a knowledge database. The user can define groups to categorize his entries. The user can create a new entry and create terms underneath each category for the entry.

Database

entries
id | name | ...
1  | Something great | ...

categories
id | name | ...
1  | Company | ...
2  | Country | ...

terms
id | name | ...
1  | Google | ...
2  | Amazon | ...
3  | USA | ...
4  | Switzerland | ...
5  | United Kingdom | ...

Relationships Table entries belongs to many categories. Table entries belongs to many tags. Table tags belongs to many categories.

I thought to go with a pivot table merging entries, categories and tags. In the end, I want to easily display the categories and the tags of each category next to the entry.

0 likes
1 reply

Please or to participate in this conversation.