• Post Reply Bookmark Topic Watch Topic
  • New Topic

creating a database structure.  RSS feed

Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got below question on an interview recently
Create a database table and coulum structure and write a sql query for a school.
where one student can be taught by many teachers , one teacher can taught many subjects, and a student participate in learning various subjects from differnt teachers.

Management wants to generate a report on like how many students a teachers teaches and which subjects. l
1000 students 200 teachers 15 subjects.

The problem is all relation between student, teachers and subjects are N:N and
since it is N:N relation beteen student and teachers, students and subjects , teachers and subjects. i startedde creating some thing below

Student table : Stud_id, name
Teacher Table : Teacher_id , name
Subject Table : Subjet_id, subject name.

now i was thinking to have a joiner table( to achieve N:N relationship)

Joiner_Student_Teacher table : ST_id, stud_id, teacher_id.
Joiner_Student_Subject table : SS_id, Stud_id, Subject_id,
Joiner_Teacher_Subject table : TS_id, Teacher_id, Subject_id.

is this database design correct for above kind of Student-Teacher-Subject Model. please give your valuable suggestions.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!