Multiple object pointer fields

Robert Brenstein rjb at robelko.com
Fri Sep 16 19:06:56 CDT 2005


>So as a follow up to this, I've now created a new table called 
>TeachStuInt.  It contains ObjectPtr fields TeacherPtr, ClassPtr, and 
>StudentPtr.  Is it bad to have three object pointer fields like 
>this?  Would it be better to create two separate tables, one for 
>Teachers and Students and one for Classes and Students?  I'm not 
>sure if any of this even makes sense to you guys.
>
>Anyway, with my new table I still can't seem to get the query right, 
>and maybe it's just because I'm not sure how the SQL should be for 
>Valentina.  I keep getting a 616 wrong expression error.  This is 
>just a simple test query that I'm running using ViSQL:
>
>SELECT Teachers.LastName, Classes.ClassName, Students.LastName FROM 
>Teachers, Classes, Students WHERE 
>Students.RecID=TeachStuInt.StudentPtr AND 
>TeachStuInt.TeacherPtr=Teachers.RecID
>
>Why does this give me the 616 error?  Can anyone help?  What is 
>proper syntax for a query dealing with a many-to-many relationship?
>
>Thanks,
>Chris

I'd approach it slightly differently

Students -- student-specific data
Teachers -- teacher-specific data
Classes -- course-specific data

instructors -- M:M table with pointers to classes and teachers
classmates -- M:M table with pointers to classes and students

The reason for having two cross-tables is that teachers and students 
are really orthogonal (independent if you will).

This allows me to find

- who is teaching each class
- what students are in each class
- what courses each teachers has
- what courses each student takes
- what teacher a student has in a given class
- all students a given teacher has
- all teachers a given student has

etc etc

I am not clear, though, what the query that you have problems with 
should yield. If you really want a listing of "teacher-class- 
student" for all entries in the database, you would need a join or 
loop through the courses and fetch teachers and students for each.

Robert


More information about the Valentina mailing list