import re


def scalarRelationship(base, local_cls, referred_cls, constraint):
    """Creates relationship name removing the schema prefix."""

    referred_name = referred_cls.__name__
    if (str(referred_cls.__table__.schema) ==
            str(local_cls.__table__.schema)):
        referred_name = referred_name.replace(
            str(referred_cls.__table__.schema).capitalize() + '_', '')

    uncamelised = re.sub(r'[A-Z]',
                         lambda m: "_%s" % m.group(0).lower(),
                         referred_name)[1:]

    return uncamelised