Implement relationships [closes #24]

Ready for review @andrewhayward