Re: Advice on SQL and records
Date: 21 Aug 2005 16:35:26 -0700
Message-ID: <1124667326.655306.310190_at_g47g2000cwa.googlegroups.com>
Stefan Rybacki wrote:
> 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
Firstly, thanks for responding so promptly. I really appreciate that.
I'm very much hoping to be corrected here, if I'm under a misapprehension, but isnt the ideal in a normalised database to have all records always only in one relevant table/object?
Thus wouldn't the StudentClasses table merely "call" the records from students through a relationship? Wouldn't StudentID be simply a field in each or the records in that table, rather than a new record?
Thanks once again for your trouble.
Fran
> >
Received on Mon Aug 22 2005 - 01:35:26 CEST