some preliminary SQL-izing backend code

note: this file doesn't really belong in this directory.
that's why this branch isn't getting merged any time soon.