Model query relations.

Implements automatic resolving of model relations when performing model queries.