One class, multiple students?

B

Bob Quintal

Heh... guess I should have seen that one. I only wanted it to show
the class once, but that is really not an option, I now realize.
:) Okay, so this will make it so that I can put in the class and
put in the student. I can list the same class and many students
(showing the same class each time), and I can have the same
student in multiple classes.

I'm used to thinking in a programming fashion, where only one
object is defined but it can have an array (or linked list) of
other objects in its definition. They are not analogous to Access
database programming, though :)

Thanks,
Eric

That third table is called a junction table.

Consider each record in a table as an array, so the whole table
becomes a two-dimensional array. The primary key of each table is
sort of the subscript to identify which ekement of the array you
work with.

The junction table is an array of pointers to the subscripts in the
main arrays (tables) It's just, in database parlance, the
subscripts are called keys. in your junction table, the keys are
foreign keys, refering to the records in othre tables.

As to showing the class once, or the student once, it's very easy to
do based on this table structure,

If you put the class info in the form header, and the student info
in the detail rows, you get the class once, and each student in a
row below that. You can even get more sophisticated, by using the
form for the class, and a sub-form for the students.
 
E

Eric IsWhoIAm

I have four tables created so far: Courses, Instructors, Courses and
Instructors (which shows the Course and Instructor Name fields, but holds
their IDs since those are the keys), and Students. Now, I wish to create a
Classrooms (or something similar) table which will allow me to pick the
Course from Courses and Instructors, and hold multiple Students for each
Course. I am unsure how to do this in Access.

Each student can have multiple classes; each class has multiple students. I
only want to store the information once, though. I can't declare an array of
Students for each class.... can I? What is the right way to do this?

Thanks,
Eric
 
K

Ken Snell

Create an additional table: CourseStudents.

In that table, put two fields: foreign key for "Courses" table, and foreign
key for "Students" table.
 
E

Eric IsWhoIAm

Heh... guess I should have seen that one. I only wanted it to show the class
once, but that is really not an option, I now realize. :)
Okay, so this will make it so that I can put in the class and put in the
student. I can list the same class and many students (showing the same class
each time), and I can have the same student in multiple classes.

I'm used to thinking in a programming fashion, where only one object is
defined but it can have an array (or linked list) of other objects in its
definition. They are not analogous to Access database programming, though :)

Thanks,
Eric
 
B

Bob Quintal

If you want to make the database even more normalized, you could
eliminate the "Courses and Instructors" table, add a third field
to the "CourseStudents" table for identifying if the record is for
a student or for an instructor, change the name of
"CourseStudents" to "CourseStudentInstructor", and use that for
both purposes.

Doesn't that violate first rule of normalization?

First Normal Form (1NF)
First normal form (1NF) sets the very basic rules for an organized
database:
Eliminate duplicative columns from the same table.
Create separate tables for each group of related data and identify each
row with a unique column or set of columns (the primary key).

http://databases.about.com/od/specificproducts/a/normalization.htm
 
K

Ken Snell \(MVP\)

If you want to make the database even more normalized, you could eliminate
the "Courses and Instructors" table, add a third field to the
"CourseStudents" table for identifying if the record is for a student or for
an instructor, change the name of "CourseStudents" to
"CourseStudentInstructor", and use that for both purposes.
 
K

Ken Snell

Ken Snell (MVP) said:
If you want to make the database even more normalized, you could eliminate
the "Courses and Instructors" table, add a third field to the
"CourseStudents" table for identifying if the record is for a student or
for an instructor, change the name of "CourseStudents" to
"CourseStudentInstructor", and use that for both purposes.

Note that, in this setup, the second field would hold either the Student
foreign key value or the Instructors foreign key value.

And, then you could have just one table -- StaffStudents -- instead of
Instructors and Students tables. And you could put instructors and students
in the same table (with fields to identify when a record is an instructor,
etc.).
--

Ken Snell
<MS ACCESS MVP>
 
E

Eric IsWhoIAm

Dear Fred,

Thank you for your suggestion! I am very much a "hands-on" type of guy, but
I am certainly going to check that out. Thank you for the tip!

Cheers,
Eric
 
B

Bob Quintal

Which is what my additional suggestion in the second post suggests
doing -- one table for "people".

I suppose that that's one way of looking at the issue. I suppose I
should have realized that "CourseStudentInstructor" means "People"
 
K

Ken Snell

Bob Quintal said:
Doesn't that violate first rule of normalization?

First Normal Form (1NF)
First normal form (1NF) sets the very basic rules for an organized
database:
Eliminate duplicative columns from the same table.

Which is what my additional suggestion in the second post suggests doing --
one table for "people".
 
L

Larry Linson

HELENA SMITH said:
my is helena smith dale jr why are not talk

Helena,

This isn't a chat room nor e-mail; it is a newsgroup devoted to Questions,
Answers, and Discussion of Microsoft Access database software. I can only
guess that you accidentally posted here, and intended to post where "dale
jr" would see your post. Probably the reason "why dale jr are not talk" is
that he doesn't participate in the newsgroup comp.databases.ms-access. It
may also be a reason why you will not see this response, because you may not
accidentally get into the newsgroup again.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top