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

mhasan's avatar

What Model structure would be best for student, teacher, course, program, batch and semister entity

Many to many relationship or many to many polymorphic relationship

0 likes
2 replies
tylernathanreed's avatar

Your models have implied meanings, so you'll have to explain a little more.

Clearly Students have a Many-To-Many relationship with Courses. Likewise, Teachers have a Has Many relationship with Courses (Unless you want to allow for a Course having many Teachers, in which case you'll need a Many-To-Many.

Other than that, what's a Program? Is that like Computer Science, where it details a series of Courses required?

What's a Batch? My best guess would be something like Math, where you can have Math Classes, but I could be wrong.

Semesters are clearly just a collection of Courses, so they have a Has Many relationship with them.

Also, I recommend adding in a Section Model, where a Course is just the curriculum, like Algebra, but a Section is an actual instance of the Course. This way, you wouldn't have data redundancy for things like Credit-Hours, Course Name, etc.

Another thing to consider is abstracting out a Person Model, because sometimes Teachers can be Students too.

1 like
mhasan's avatar

Thanks for your clear description, and sorry for not providing enough details of the entities: here is the details:

program is like grade1, grade2, grade3 and so on course: English, Bengali, Math, etc batch: 2015, 2016, 2017 etc semister: 1st, 2nd, half-yearly etc

Note: I have users and roles with many to many relationship. Also to separate from users, I also have student and teacher model. Both of these model have one to one relationship with user model.

Basically, I am trying to build a app for south Asian elementary and middle schools.

Please or to participate in this conversation.