Implement database support.

Closes #5.