Sql backend: basic implementation and some tests

Also a few raco refactoring and fixes inline.

@7andrew7 take a gander? To be honest, I kind of / really hate this.
Something like this seems right. I think the real need is to properly abstract the fakedb interface -- I think it's actually poised to be the basis for things like federated as well.