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.