Added referential integrity to script