TotalWhat Posted April 26, 2015 Share Posted April 26, 2015 Hey! So I have a database that handles students, courses and registration. I have a table called Assignments which has three values "courseCode", "assignmentName" and "points". I have a table called Students that has the value "pnr". I have a table called Courses that has the value "courseCode". I have a table called Studies that has the values "courseCode", "pnr" and "assignmentName". I have a table called HasStudied that has the values "courseCode, "pnr, "assignmentName" and "grade". Now I need a check, constraint or trigger of some type that will prevent the administrator from being able to register a student to too many courses. A student can read 45points of courses as maximum. How would I go about this? Thank you! Link to comment Share on other sites More sharing options...
TotalWhat Posted April 26, 2015 Author Share Posted April 26, 2015 This is as far as I have come: create trigger CourseEnrollmentTriggeron Studiesinstead of insertasbeginselect sum(assignmentPoints) as Points from Assignment a join Studies son a.courseCode = s.courseCode and a.assignmentName = s.assignmentName and a.sectionName = s.sectionName and pnr = '851326'if < 45end go Link to comment Share on other sites More sharing options...
davej Posted April 26, 2015 Share Posted April 26, 2015 Is this MySQL? https://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html Link to comment Share on other sites More sharing options...
TotalWhat Posted April 27, 2015 Author Share Posted April 27, 2015 MSSQL Link to comment Share on other sites More sharing options...
davej Posted April 27, 2015 Share Posted April 27, 2015 From what I remember triggers are rather limited in what they can accomplish, so you may need to have the trigger call a stored procedure. https://msdn.microsoft.com/en-us/magazine/cc164047.aspx https://msdn.microsoft.com/en-us/library/ms178110.aspx https://msdn.microsoft.com/en-us/library/ms190227.aspx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now