1 author can have many books / 1 book can have many authors
When an author is deleted, how can I trigger MySQL (SQLite) to delete books whose author is only uniquely the one being deleted on authors, so it won't have books without authors associated to it?
Example:
BOOK1: John & Paul
BOOK2: John
BOOK3: Lucy
BOOK4: John & Lucy
if I delete john from authors then the trigger would delete BOOK2 only.
authors_books' both foreign keys: ON DELETE CASCADE
Aucun commentaire:
Enregistrer un commentaire