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

dib258's avatar
Level 11

Multiple n-m relation tables

Hi,

I'm designing a database for a website and I'm in a bit of a situation.

database-conception

In the drawing just above you can see I have 5 tables. Users, Projects, Moderators, Tags, Comments.

So, to explain it a little. A user can create a project, and a moderator can put a comment on a project. But they can both put one or more tags on a project.

So in my conception, there'll be 3 link tables more. I don't know if it is the best for Eloquent and if I'll get the result I want.

Also, I separated users an moderators so in the eloquent classes I don't have methods from users an moderators.

Thanks in advance for your help !

0 likes
4 replies
pmall's avatar

Yes but a moderator is an user. What differentiate them ?

1 like
dib258's avatar
Level 11

Like I said they are both users in a kind of inheritance way but I decided to separate them to be more rigorous in OOP with Eloquent. They have some differences in their attributes but mostly by separating them, a moderators can post a comment, add a tag to a project. And the user can create a new project and add a tag on it.

dib258's avatar
Level 11

Ok, so you all says that I shouldn't separate moderators and users but in my case I don't want moderators to be able to create a project and users to comments a project. I know this stuff can be down in the php. But I prefer a clearer DB that reflect what it's supposed to be.

Maybe should remove the tags table and insteand use two links table 'project_user' and 'moderator_project' and put the tag in it. There would be duplicate of the tags but it's not a lot of data.

Please or to participate in this conversation.