mysql - proper way to delete album and its media and sub album and its media -


Will the album be the proper way to delete the sorted data with your media?

Would I just start looping and find all sub album ids and want to delete thous and create a query to delete all media related to that album id.

This query may be loaded in performance if the data is too many for one or one album

The structure of my database:

  ** Album ** album_id name parent_id ** media ** media_id album_id name  

  Remove from album, media WHERE media.albumID = albums.albumID and (albums.parentID =? Or album. AlbumID =?)  

This is a simple way, assuming that your data Triggers or relationships have not been defined Hard to give your best answer without knowing more about your specific database structure; However, with other situations, why are you better than doing this as a single SQL statement? This protects your data integrity, otherwise you have to issue locks on various tables, while your software manually deletes specific entries (which is also a solution, but knowing more, I do not want to recommend ).


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -