1. for one-to-many: teacher 1: n students the order of save: save teacher, save students, update students with teacher id the order of delete: update students, set teacher = null, delete students, delete teacher
So for those order, we can see that, if there is any foreign keys setting in the table of students, the foreign key can‘t be set as 'not-null', because we can see that when save, the student was saved with null id of teacher, and when delete teacher, the teacher id of students will be set as null at first step.
本文探讨了一对多关系中教师与学生之间的数据保存及删除顺序。为了保持数据一致性,在保存时先存教师再存学生,并更新学生的教师ID;删除时则先解除学生与教师的关联,再删除教师信息。
1279

被折叠的 条评论
为什么被折叠?



