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

shadrix's avatar
Level 12

Help: Should I use a pivot table or a normal eloquent model? (two foreign keys)

I'm trying to implement these two tables "enrollment" and "learning_progress". Look at this diagram to understand it:

enter image description here

I'm a bit confused because of the two foreign keys. Usually, this means it's a many to many relationship. Should I use these tables as a pivot table? Or is it still a normal eloquent model.

One thing is weird for me. How would you name these tables? The first enrollment pivot table could be courses_student table. But the second would be super weird like: course_chapter_content_courses_student...

0 likes
1 reply
MichalOravec's avatar

enrollment has to be a normal table, because you use enrollment_id in the learning_progress table.

learning_progress could be a pivot table.

But table name is better to have in plural form.

1 like

Please or to participate in this conversation.