I am developing an educational institute management system where I need to assign teacher, subject and paper to the courses. So I've created a schema course_subject_paper_teacher where I am storing the course, subject, paper and teacher's id. But things are getting so much complicated when I am going to fetch data from that table. For example I need to show all subjects of a course in comma (,) separated format. Also the subject name along with its papers and contents separately and unique teachers (one teacher can teach many subject and paper in a course) record along with their teaching subjects in comma separated format. Can you please suggest a better database schema for my current requirement? Thanks in advanced 😊
@martinbean No I mean I need to show the name in comma separate format. Basically I am assigning a teacher for a particular subject and a particular paper. For example in course id of 1, teacher id of 1 can teacher the paper of id 1 of the subject of id 1
@martinbean I need to store the record of which teacher is teaching which subject and which paper of a particular course. For that I'd used course_subject_paper_teacher where there are 4 foreign keys - course_id, subject_id, paper_id and teacher_id. This becomes complicated when fetching data from that table. Since teacher assignment are subject and paper specific (teachers are not bound in a specific subject or paper, means they can teach multiple subject based on the assignment).
@martinbean Basically in the course details page there are 3 tabs. First tab I need to show all teacher assigned to the course with their teaching subjects (in comma separated format). In the details tab I need to show the subject name, subject paper name and their content (content stores as json in the paper table).
@pranaycb Again, that has no bearing on your database schema. It wouldn’t matter if you wanted to show names in a comma-separated format, a definition list, a table, a QR code… it wouldn’t change how you would model and store that data.
Stop conflating how you’d structure and store that data, with how you’d present that data.