Separate database definitions into modules

`database.coffee` was getting long and hard to maintain