Re: Advice on SQL and records

From: Stefan Rybacki <stefan.rybacki_at_gmx.net>
Date: Sun, 21 Aug 2005 11:13:04 +0200
Message-ID: <3mqusuF1884v0U1_at_individual.net>


fran_beta_at_hotmail.com wrote:
> 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
>

I guess that is right in the average case.

> How would this be determined? Why wouldn't Students contain the most
> records?

Imagine 10000 students. So your students table has 10000 entries. Now say each student take part in one class, so studentclasses has 10000 entries. But because usually a student takes part in more than one class say 3, you have 30000 entries in studentclasses.

Stefan

>
> Thanks
>
> Fran
>
Received on Sun Aug 21 2005 - 11:13:04 CEST

Original text of this message