Move table definitions to separate file

Also, restrict studies query to namespace
Import xsd:duration as PGInterval
Fix arm_size to be integer
Import nearly all tables

 - re-enable enum types
 - import datetime
 - add table definitions
 - some refactoring of SQL schema