Re: Advice on SQL and records

From: Stefan Rybacki <stefan.rybacki_at_gmx.net>
Date: Mon, 22 Aug 2005 11:29:44 +0200
Message-ID: <3mtk8aF150bd2U1_at_individual.net>


fran_beta_at_hotmail.com wrote:

>...

>
> I guess the problem is "what exactly are the records in
> 'StudentClasses'"?

One "record" in StudenClasses represents exactly one relation between Student and Classes of the m:n relation

>
> It seems implicit from what you say that StudentClasses includes all
> ClassID records AND all StudentID records, whereas I assume that only
> ClassID records would be in there.

Not at all, as long as there could be students that not attend any class or there is an empty class. Whatever the usual case is that any student attending at least one class, so you create at least student count relations to one or more classes in StudentClasses. This means you have at least student count "records" in StudentClasses.

>
> Thus even if there are 10000 students if the college is running for
> example, 40 different classes, there would only be 40 records in
> StudentClasses, even if each of these records had a minimum of 30 and a
> maximum of 100 student names in it.

No. I guess you first have to understand what StudentClasses is for.

Say in real world you have a student call him Bob. There are 3 classes that are available to attend. Say now Bob attends class 1 and only class 1. How would the tables look like?

class
classid name

1	class 1
2	class 2
3	class 3

student
studentid name
1 Bob

StudentClasses
classid studentid
1 1

So what does the record (1,1) in StudentClasses mean? It means, the Student indentified by ID 1 attends the class identified by ID 1 (Student 1=Bob, Class 1=class 1 -> Bob attends class 1)

Now say Bob attends also class 3.

StudentClasses
classid studentid

1	1
3	1

Now there are two "records" (Student 1 attends class 1 and class 3) You have to add one record for every class one specifc student attends. This leads to the fact that you have to add at least one record for every student in the student table.

Stefan

>
> Is it the case that records contain records?
>
> Thanks for your continuing interest.
>
> Fran
>
Received on Mon Aug 22 2005 - 11:29:44 CEST

Original text of this message