Hi guys,
I am creating a university database, where student can take sections and courses have prerequisites. I have to make sure that when user takes a section, he has met all the prerequisites for that course he is signing up for. And, when a course is deleted from the database, i have to make sure that the course to be deleted doesn't have any prerequisites.

here is my schema
Student(studentid, firstname, lastname, major, gpa)
course(courseid, title, credit)
requires(courseid, prerequisiteid)

I am not sure how do this in MYSQL. Can you guys get me started in the right direction?


8 Years
Discussion Span
Last Post by alkeshtech

create relation in requires table. both column will take value from course table. do not allow casacade update or delete to protect related data from deleting.


Yep that will work, but how do I check that a student has met all prerequisites when he wants to take a course?


Where in your schema do you record the fact that the student is taking, or has taken some courses? I think you need a table that has a one-many relation associating each student to courses that student is taking or has taken.

StudentCourses (studentid, courseid, date_completed)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.