Re: Foreign Keys Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2008-12-11 at 13:46 -0500, tedd wrote:
> At 12:29 PM -0600 12/11/08, phphelp -- kbk wrote:
> >Hey tedd ---
> >
> >Do I understand your structure correctly that you have something like:
> >
> >Courses (table)
> >course_id,
> >subject_id,
> >student1_id,
> >student2_id,
> >student3_id,
> >student4_id,
> ><etc.>
> >
> >Is that right?
> >
> >Ken
> 
> Ken:
> 
> That was right, but I think I've reconsidered.
> 
> You see, Richard pointed out the error of my ways, namely:
> 
> Student table has student data and ID -- as may records as there are students.
> 
> Instructor table has instructor data and ID -- as may records as 
> there are instructors.
> 
> Course table has course data, ID and Instructor ID and Student ID -- 
> but the number of records vary.
> 
> While there will be only one record per Instructor and one pre 
> Student, the Course table can have up to four records for each course 
> depending upon actuall attendance.
> 
> I think that makes more sense.

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.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux