Delete function includes delete reference table