Hello there,
I have a problem with referential integrity in InnoDB. Let's say I have three tables: Author, Book and Author_Book which joins Author to Book (a book can have multiple authors and an author can have written multiple books). I have defined foreign keys from Author_Book to Book and from Author_Book to Author. If I delete an author, the relevant record is deleted from Author_Book. If I delete a book, the relevant record is also deleted from Author_Book. However, I would also like that, if I delete an author, all books written by this author (and only this author) are also removed from the table book (and not only from Author_Book). This behaviour should of course not happen if a book has multiple authors. Is there any way I can achieve this?
Thank you in advance.
xso
I have a problem with referential integrity in InnoDB. Let's say I have three tables: Author, Book and Author_Book which joins Author to Book (a book can have multiple authors and an author can have written multiple books). I have defined foreign keys from Author_Book to Book and from Author_Book to Author. If I delete an author, the relevant record is deleted from Author_Book. If I delete a book, the relevant record is also deleted from Author_Book. However, I would also like that, if I delete an author, all books written by this author (and only this author) are also removed from the table book (and not only from Author_Book). This behaviour should of course not happen if a book has multiple authors. Is there any way I can achieve this?
Thank you in advance.
xso