Please take a look at the diagram below:
This all ties around if a user is deleted.
1. If a user is deleted, and the user has a thread. The thread will be deleted.
2. If a user does not have a thread, but has posts, the posts will be deleted.
3. If a thread is deleted, ALL posts on that thread is deleted.
I tried to cascade User->Thread, User->Post, Thread->Post. However, I get this exception: Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths. Specify on delete no action.
I sort of understand the error. If a user is deleted, both thread and post is deleted, so when thread is deleted, it will try to cascade post, which has already been cascaded by user. (Is this right?)
So if the above is true, how can I solve this?