sort out the db

* add indexes
* disallow nulls