protected function locateOuter(
        SchemaBuilder $builder,
        RelationDefinition $definition
    ): RelationDefinition {
        /**
         * todo: add functionality to resolve database alias
         */

        if (!empty($definition->targetContext())) {
            //Nothing to do, already have outer parent
            return $definition;
        }

        $found = null;
        foreach ($builder->getSchemas() as $schema) {
            if ($this->matchBinded($definition->getTarget(), $schema)) {
                if (!empty($found)) {
                    //Multiple records found
                    throw new DefinitionException(sprintf(
                        "Ambiguous target of '%s' for late binded relation %s.%s",
                        $definition->getTarget(),
                        $definition->sourceContext()->getClass(),
                        $definition->getName()
                    ));
                }

                $found = $schema;
            }
        }

        if (empty($found)) {
            throw new DefinitionException(sprintf(
                "Unable to locate outer record of '%s' for late binded relation %s.%s",
                $definition->getTarget(),
                $definition->sourceContext()->getClass(),
                $definition->getName()
            ));
        }

        return $definition->withContext(
            $definition->sourceContext(),
            RelationContext::createContent(
                $found,
                $builder->requestTable($found->getTable(), $found->getDatabase())
            )
        );
    }