add zsql method to get delete gid & pref to know when to check it
implement deletion checking using SQL