SQLite Forum

Please explain the error on insert
Why does your design declare student_prev to be NOT NULL if you clearly want to enter "nil pointers" in your data? It Forces you to use 0 as a marker for the end of the list and to violate referential integrity.

Also, do you really want to kick out all students attached to a teacher when you remove a teacher (ON DELETE CASCADE)? This seems a Little drastic. Maybe you would rather reassign all attached students (ON DELETE RESTRICT) first? Or maybe make them unassigned (ON DELETE SET NULL), which would probably mess up your linked list without some further code.