Re: Foreign Keys Question

From: Date: Thu, 11 Dec 2008 19:32:51 +0000
Subject: Re: Foreign Keys Question
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-284500@lists.php.net to get a copy of this message
At 1:55 PM -0500 12/11/08, Robert Cummings wrote:
Student attendance should be a table with rows for each student in attendance. If you want to limit the number make a check before adding another student. Don't hard code the number via fields like above or you'll find it overly ugly to add/remove students or even increase the number of allowed students. As it stands to allow 6 students you would have to add 2 more columns. With attendance controled by a table with a row for ewach attendance you would only need to update a configuration variable the determines the maximim number of allowed students in attendance. Cheers, Rob.
Rob: I see -- the solution is a table for courses, students, instructors and enrollment. The enrollment table will hold links to all (third normal). If I want to limit the number of students in a course, then just count the number of students enrolled in a specific course within the enrollment table and check that number against the maximum allowed before adding another enrollment record. Also, if a student cancels, then it's only a deletion of an enrollment record and all is right with the world. That's good. Sometimes it's good to talk things like this through -- clears the fuzzy thinking. Thanks, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#284500) next »