updated sql for primary key