Schema changes

Database schema changes, as requested. The first commit 90777e6 has the details.

This PR will require a database schema update.