Added an event handler to delete relationship in dtatbase if a resource gets deleted.