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

syntaxerron's avatar

Access child data from parent with multiple child relationships.

I have three tables: users, employees, and customers. The users table is the parent, while employees and customers have foreign key user_id as reference to the users table. I am confused how to get the specific child data of the users parent if its an employee or customer. I get the idea of a one-to-one relationship and how I can access on both sides, but is there any resolution to this case where a parent can have two child models like below:

User 1 has Employee 1 details; User 2 has Customer 1 details

To access User 1 details, I need to check if its from employees or customers table. Just wondering if anyone has experience doing this and how it can be accessed?

0 likes
2 replies

Please or to participate in this conversation.