Re: Advice on SQL and records

From: David Cressey <david.cressey_at_earthlink.net>
Date: Thu, 25 Aug 2005 12:28:20 GMT
Message-ID: <EPiPe.1788$_84.678_at_newsread1.news.atl.earthlink.net>


<fran_beta_at_hotmail.com> wrote in message news:1124611376.749896.208510_at_o13g2000cwo.googlegroups.com...
> I'm teaching in computing. A question appeared in a trial paper
> recently and I'm trying to establish whether the suggested answer is
> correct.
>
> The question was:
>
> SELECT Students.Surname, Students.Name
> FROM Courses, Classes, StudentClasses, Students
> WHERE Courses.CourseID="10MA"
>
> AND
> Courses.CourseID=Classes.CourseID
> AND
> Classes.ClassID=StudentClasses.ClassID AND
>
> StudentClasses.StudentID=STudents.StudentID
>
> ORDER BY Students.Surname, Students.Name
>
>
> Which of the tables is likely to contain the most records?
>
> The suggested answer from Courses; Classes; StudentClassses and
> Students was:
>
> StudentClasses
>
> How would this be determined? Why wouldn't Students contain the most
> records?
>
> Thanks
>
> Fran
>

During the course of this discussion some of us have mistakenly substituted "StudentCourses" for "StudentClasses"
in the description of the problem. The difference is important.

The case outlines, with near minimal complexity, both a many-to-many relationship and a many-to-one relationship.

StudentClasses illustrates a many-to-many relationship, using two foreign keys in a table built for that purpose.
Classes.CouseID illustrates a many-to-one relationship, by adding a foreign key to an existing table (relation).

If the m-to-m table were StudentCourses, instead of StudentClasses, it would be impossible to print out a class roster. Received on Thu Aug 25 2005 - 14:28:20 CEST

Original text of this message