I have these tables:
items:
+ _id
+ timestamp
itemlists:
+ _id
+ timestamp
linktable:
+ _id
+ item_id foreign key references items(_id)
+ item_list_id foreign key references item_list(_id)
An item can be in many lists. A list can contain many items. It's a many-to-many relationship.
I now want to delete an itemlist and all items in it, if they are unique to that list. However I don't want to delete any item from items table if they are in another list as well.
I can retrieve all items for a specific playlist:
items a inner join item_list b on a._id = b.item_id where item_list_id = ?
But I'm struggling with how to structure a delete for a specific list and its items, without deleting items that are also referenced by another list that is not deleted.
Any pointers in the right direction are highly appreciated.
I'm running this on SQLite on Android.
dropTable?