start of db backend

Got some bits working.  I ignored the json bit, because I'm a bit concerned about how that will work, but I'll explain that on the mailing list.

Cheers,
Aaron