sql updated

sql updated for finalized database