add a few constraints

* and fix missing measurements!
use PostgreSQL, prevent NULLs and do the right GROUP BY
set minimal_time if not present
add a few column constraints