Depends on how relations need to be setup. School has students. Student belongs to a school.
Re-study some of the relation examples from documentation.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I have a schools table, a classes table, and a students. The schools table and the classes table are related through a foreign key on the classes table. The same goes for the classes table and students table.
My question is, If I want to list all the students from a school, should I loop through all the classes and then get the students? Is it bad practice or redundant to add an extra foreign key to the student's table that refers to the school id?
hopefully this will help u: https://www.youtube.com/watch?v=5s-_SnVl-1g
Please or to participate in this conversation.