Paul Clapham wrote:But inserts have nothing to do with joins. You can't insert into the result of a query involving a join. If you want to insert into two tables, then two inserts are required -- one for each table. You should consider creating a transaction to contain the two inserts, so that you don't end up with inconsistent data because only one insert was done and the other insert failed for some reason.
As for your Scheduling table: if it has a foreign key relating it to the Subject table, as it appears to do, then its "teacher_id" column is redundant. The Subject table already has that column.
Likewise I don't understand why the Student table has a "course" column. But this time the problem is that I don't understand what "course" means there. To me a Course is something like "Philosophy 403 (First-order Predicate Logic)" and such a thing wouldn't belong in a Student record. The Student could certainly be registered for that course but then you'd have another table to record that fact, since Student::Course would be an N-to-N relationship. But perhaps "course" means something else in your design?
Jobert John wrote:>Oh right two FK of teacher_id. (But im using Joins like Schedule and Teacher, Schedule and Subject, Schedule and Student I dont use them for var. interlapping is that ok or my logic is wrong?)
>Course is kinda like department of the teacher table
So what is the better approach for my problem?
You're using ordinary words which mean obvious things in the context of students attending a school and taking courses. If you don't intend those words to have their ordinary meanings, you'd be better off to use other words. Preferably other words which reflect what the tables are supposed to represent. Preferably words whose ordinary meanings are what the tables are supposed to represent. If you don't do that then you should say what your meanings are for those words. I find that examples often help.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |