Add SQLite support, and some other bits

Also added relationship caching for ms sql server