Updated query statements and database

Update was to reflect that primary keys exists and values that are not
null.