def METHOD_NAME(datamodel, tables, classes):
    def map_class(tabledef):
        cls = classes[ tabledef.name ]
        table = tables[ tabledef.table ]
        def make_relationship(reldef):
            if not hasattr(reldef, 'column') or reldef.relatedModelName not in classes:
                return
            remote_class = classes[ reldef.relatedModelName ]
            column = getattr(table.c, reldef.column)
            relationship_args = {'foreign_keys': column}
            if hasattr(reldef, 'otherSideName'):
                backref_args = {'uselist': reldef.type != 'one-to-one'}
                if remote_class is cls:
                    backref_args['remote_side'] = table.c[ tabledef.idColumn ]
                relationship_args['backref'] = orm.backref(reldef.otherSideName, **backref_args)
            return reldef.name, orm.relationship(remote_class, **relationship_args)
        properties = { tabledef.idFieldName: table.c[tabledef.idColumn] }
        properties.update({ flddef.name: table.c[flddef.column]
                            for flddef in tabledef.fields })
        properties.update(relationship
                          for relationship in [ make_relationship(reldef)
                                                for reldef in tabledef.relationships ]
                          if relationship is not None)
        orm.mapper(cls, table, properties=properties)
    for tabledef in datamodel.tables:
        map_class(tabledef)