Add relation feature to the new API with tests.

The test code is beginning to develop a bulk of code duplication that I'll factor out and tidy up in a follow up PR.

@housejester ping :smiley: