Matthew Ruffell, founder of Dapper Linux, has created an excellent tutorial about writing charms that make use of a PostgreSQL backend.
Juju deploys Charms , a set of instructions on how to install, configure and scale a particular software package. To be able to deploy software as a Charm, a Charm has to be written first. Usually Charms are written by experts in operating that software package, so that the Charm represents the best way to configure and tune that application. But what happens if no Charm exists for something you want to deploy?
Matthew goes into depth about how to implement several important features, including configuration and hooks. He even details creating a custom icon for his charm, which I thought was a really nice touch.
Once you’ve read through this one, you should also take a look the “Tiny Hooks Charm” tutorial from @erik-lonroth: