Many-to-Many Relationship – Student and Course Relationship with Grade and Attendance

many-to-many

I was reading on this DBA page, about Student and Course relationship, and the use of a junction table. Suppose I wanted to do two things:

  • Include the student grade for each course
  • Allow the professor to generate an attendance sheet of students

I have a Student table like this:

Student (id, first name, last name)

Student_Course (student_id, course_id)

Subject (id, name, professorID)

Can I place the grade in the Student_Course table? What table can I use to generate an attendance sheet with StudentID, and First/Last name? I'm guessing attendance would be a query.

Best Answer

As the student's grade is logically tied to both the student and the course, Student_Course is the best place to put it.

For attendance, you would indeed use a query. You can't generate the attendance sheet from one table. You're starting from a professor and/or course name, and need to get data out of the Student table. I suppose you'd need to have some way to connect the professor to the students. In the query, you'd need to find a way to tie each of the tables together. I'd check the documentation for your database, and see if it mentions any way to join tables together in a query.