Suppose there are two tables "teacher" and "schoolClass".

"teacher": ID, Name; classID. "schoolClass": ID, Name, TeacherID 

"teacher.classID" - points to the ID from "schoolClass", "schoolClass.TeacherID" - points to the teacher ID in the first table. Is it possible at the base level to make so that when you save (add) a teacher with a filled "classID" , the changes are reflected in the table "schoolClass": TeacherID and vice versa: when you save the class, the changes also take place in the "teacher". Which way to google?

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

This can not be done and, most importantly, not necessary. Imagine that, for example, we have a many-to-one relationship, then we have a problem when changing the side that contains many, this problem is what value from the set of keys on the many side we need to update the field on the side one. " The many-to-many relationship is solved by creating an additional table. And the relation "one to one" removal FOREIGN KEY , from one table. And by adding another table to the field other than FOREIGN KEY , UNIQUE , and possibly CASCADE .

You need to read about data normalization.