I\'ve read some of Bill Karwin\'s answers about single table inheritance and think this approach would be good for the setup I am considering:
Playlist
--------
The answer by Zane Bien is quite obvious & superb.But I have an idea for doing this without use of trigger because trigger has many problems.
Are you using any programming language ? If yes then,
Use a single transaction
and make your database auto commit false
write a delete query for the referenced rows in Playlist and PlaylistVideo . Manually you have to write this query first by using that reference id(with where condition) and run it.
Now prepare another query for your main task i.e. delete the User, and the rows in UserPlaylist will be deleted automatically ( due to CASCADE DELETE
option).Now run your second query and commit
.
Finally make your transaction auto commit true
.
It is working successfully, hope it will helpful.