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

georgek's avatar

Tags relation with 2 tables only

I have a model "People" and one more model "PeopleTag". Example records:

People: #1 George #2 Lara #3 John

PeopleTag: #1 - 1 - tall #2 - 1 - male #3 - 1 - friend #4 - 2 - female #5 - 2 - friend #6 - 3 - visitor #7 - 3 - male

What I want is to create a belongstomany relation between them without using a 3rd tables. Normally I had to do it like:

PeopleTag: #1 - tall #2- male #3 - friend #4 - female #5 - visitor

People_PeopleTag: #1 - 1 - 1 #2 - 1 - 2 #3 - 1 - 3 #4 - 2 - 4 #5 - 2 - 3 #6 - 3 - 5 #7 - 3 - 4

But I dont really need to have a 3rd table in that case. Would it be possible to have belongstomany relation with 2 tables only on this example?

0 likes
0 replies

Please or to participate in this conversation.