I'm trying to design a database for the information shown in the table
below:
In this regard, let's make the following assumptions:
- Each Student may take many Courses
- Each Course may have many Students
- Student Numbers, Course Numbers and Advisor Names are unique
- Student Names and Course Descriptions are not unique
- Each Student has one Advisor
- Each Advisor may advise many Students
- Each Advisor has one Office
- A Student can visit with his Advisor many times
My current approach
So far, I have come up with the following diagramatic representation:
The question
Being that this contains a many-to-many (M:N) relationship, I am confused as to what the association class (or associative entity type) should be.
What would the correct way to represent this relationship be?
Best Answer
You could have a
Course
table which would just contain the courses and descriptions.As stated in the comments, you could then have a
StudentCourse
table which had either a surrogate PK, with foreign keys toStudent
andCourse
or a composite PK (StudentNumber and CourseNumber) with the Grade for the student held in it.Similarly, you could have an
Office
table and link the Office back to the Advisor. This would allow multiple advisors to have the same office without having to hold the office name multiple times (what if the office name changed for example?).As also mentioned using the Advisor name as the primary key might not be best, their name could change; you might be better to use a Surrogate key (integer perhaps?) for that.