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

kgp43's avatar
Level 2

What type of relations should I use?

Hi,

I'm not sure if "relations" is the right word, but let me try explain what I need to do.

I have these 3 tables that is related to my problem: companies, users and notifications.

A user signup to my app and can use it for different tasks. One of those tasks, are notifications. The user can choose what type of notifications we would like to receive from each company (if any). Users can set individual notifications-settings for each company that he is associated with. He might want to be notified when "Company A" has new product releases and sales, but he does not want the newsletter. Another user might have other settings.

How should I handle this and what is this type of.... method/function.... called? I was planning to add all the different "relations" to the notifications table, but not sure if that is a good idea or not.

Any suggestions how to keep track of all this?

0 likes
5 replies
kgp43's avatar
Level 2

No, I did not try to search for "tree table".

I thought I had to search using an advanced word that I dont know... thats why I created this topic. To learn the name of the relation :)

kgp43's avatar
Level 2

Most of those topics that I read is 2 tables + 1 pivot table. But I need 3 tables + 1 pivot table, correct?

users, companies, notifications, pivot

notifications table contain all the different type of notifications, such as: "newsletter", "sales", "new_products", "price_changes" etc.

Or should I add the notification type to the pivot table and remove the notifications table? A column named ... type? Containing the type of notification (newsletter, sales... etc).

kgp43's avatar
Level 2

Thanks and sorry for the late reply.

Please or to participate in this conversation.