How to enforce referential integrity on Single Table Inheritance?

后端 未结 4 2035
一生所求
一生所求 2021-02-19 09:11

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
--------
         


        
4条回答
  •  庸人自扰
    2021-02-19 09:52

    OK I see what you want here... what you want to do is run a query like

    DELETE FROM playlist
    WHERE       id 
    NOT IN      (
        SELECT  id
        FROM    UserPlayList
        UNION
        SELECT  id
        FROM    TeamPlayList
    )
    

    after either a row is deleted from either users or teams

提交回复
热议问题