protected function renderRelations()
    {
        foreach ($this->schemas as $schema) {
            foreach ($schema->getRelations() as $name => $relation) {

                //Source context defines where relation comes from
                $sourceContext = RelationContext::createContent(
                    $schema,
                    $this->requestTable($schema->getTable(), $schema->getDatabase())
                );

                //Target context might only exist if relation points to another record in ORM,
                //in some cases it might point outside of ORM scope
                $targetContext = null;

                if ($this->hasSchema($relation->getTarget())) {
                    $target = $this->getSchema($relation->getTarget());

                    $targetContext = RelationContext::createContent(
                        $target,
                        $this->requestTable($target->getTable(), $target->getDatabase())
                    );
                }

                $this->relations->registerRelation(
                    $this,
                    $relation->withContext($sourceContext, $targetContext)
                );
            }
        }
    }