Delete parent object when all children have been deleted in sqlalchemy
问题 Let's say I have the following relation: Reference(slide_id, group_id) where reference is the association of a slide and a group. One slide can be used in many references (with a different group): primary key is slide_id + group_id , which must be unique. I want to have all the references deleted when either of the pointed group or slide are deleted. Which I do by adding a cascade in the backref of the relationship: # definition of Reference model slide = db.relationship( Slide, backref=db