basic identifier validation

sql was the least painful way i could think of to do this,
uses an in-memory db instance