MySQL Forums
Forum List  »  Newbie

Re: Select an array from one databank and compare it to one from another databank
Posted by: Barry Galbraith
Date: November 25, 2015 03:47PM

The relationship between teachers and subjects is what's termed many-to-many.Any subject can have many teachers, and any teacher can teach many subjects.

By keeping the subjects in a table of their own, you have a list of subjects to display in a dropdown list to select from for people who want to request a teacher.
Getting that list from your "teachers" table could be a problem.
In my example, "bass" and "bass guitar" would be basically the same thing, but you could have two separate entries in your teachers table, but more likely only 1 in my "subjects" table.

If your "teachers" table has contact info and such on each line that contains a subject, and the contact info changes, you have to be careful to change it on every line for that teacher. It's called skew, and that's bad.

IMHO,
"Teachers" should contain info about the teacher.
"Subjects" should contain a list of subjects, and info about them.
"Teach_subj" should contain pointers to who teaches which subject. (Many-to-many).
"Requests" should contain info about individual requests, like who wants what and where they want it.

Your query can then tell you who can teach the subject in the request.

In the final washup, how you organize your data is up to you. You should lookup "normalization" for more info and ideas.

The more you normalize your data, the more useful it can become.

Feel free to keep asking questions about anything you don't understand.

Good luck,
Barry.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.