Implemented basic auxiliary fields for ForeignKeys.

This commit has somewhat disastrous effects on the test suite, causing 199
failures and 1104 errors on SQLite, but it's a start.