1

I'm very new in designing professional database system and making a School Management System in Laravel. I have issues setting my database. How to enroll a student. To know the problem, you must have to read requirement once.

Every Classroom can have minimum 1 or maximum many Section. Every Section has many list of Courses and Students enrolled in. Every Classroom has Teacher

The database I am thinking for this is

  • Student (many-to-many forming Registration ) Classroom

  • Classroom (many-to-many forming Class_Section ) Section

  • Section (many-to-many forming Section_Courses ) Courses

or

  • Student (many-to-many forming Registration ) Classroom

  • Classroom {class_id, section_id(FK)} (one-to-many ) Section

  • Section {section_id, course_id} (one-to-many ) Course

The thing I need is that when enrolling a student, I want to register him in the ClassRoom and in any section of that classroom. A Student can see all the courses in that section.

This makes clear that registration should have section id as well. But if I make relation of a section with registration. It will show all sections.

Kindly suggest me a possible way of designing this database. I'm stuck up here and can't find a better option for it.

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Abdul Rehman
  • 159
  • 1
  • 2
  • 18

1 Answers1

0

Mainly there are three types of relations. They are, 1. one to one 2. one to many 3. many to many

Think about every relation from both ways. For example, you have said that,"Every Section has many list of Courses." Now think it in reverse. Can a course be offered in more than one section? If yes, then it should be a many to many relation. Otherwise it should be one to many.

Similarly think about classroom and section relationship. You have said, "Every Classroom can have minimum 1 or maximum many Section". Now think about it in reverse. Can a section have more than one classroom? If it can have more than one classroom then you need many to many. Otherwise, one to many will be ok.

The main point is if it is "one to many" from both sides then you need a many to many relation.

About showing only courses for that section; don't worry about it. First design the database. Laravel handles relations extremely well. In fact, eloquent relationship is very powerful tool. You can also use polymorphic relation and intermediary relation. Try to read about it from documentation.

Nabil Farhan
  • 1,444
  • 3
  • 25
  • 41