Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 designing database for many-to-many relations

Author  Topic 

jonekim
Starting Member

35 Posts

Posted - 2011-11-22 : 03:19:12
I am designing a database for School management System.

My tables are:
1. students (student_id, student_name)
2. teachers ( teacher_id, teacher_name)
3. courses ( course_id, course_name)

here the relation b/n students and courses is many-to-many i.e. one student can enroll to many courses and one course can be enrolled to many students.
and relation b/n teachers and courses is also many-to-many i.e. one teacher can teach many courses and one course can be taught by many teachers.

My query is to show:
1. show the list of enrolled course by a student
2.show the list of courses taught by a teacher
3. show the list of students enrolled for a particular course
4. show the list of teachers assigned for a particular course

how to design a database for such query? What can be the possible entities for the above tables?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-22 : 03:26:09
you need to add bridge tables for representing the many to many relationshipd. Add two tables course_tutors with teacher_id,course_id to represent teacher course relation and course_participants with student_id,course_id to represent student course relation

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -