public static RelationTableInfo createRelationTableInfo(NamedDescription relation) {
    { RelationTableInfo self000 = RelationTableInfo.newRelationTableInfo();

      self000.relation = relation;
      { RelationTableInfo tableinfo = self000;
        RelationColumnInfo columninfo = null;
        int arity = relation.ioVariables.length();
        Cons columns = Stella.NIL;
        Module defaultmodule = ((Context)(Stella.$CONTEXT$.get())).baseModule;

        tableinfo.database = Logic.accessBinaryValue(relation, RDBMS.SGT_RDBMS_RELATION_DATABASE);
        tableinfo.dbmsName = ((tableinfo.database != null) ? edu.isi.sdbc.Connection.getDbmsName(RDBMS.getConnectionFromDatabase(((LogicObject)(tableinfo.database)))) : RDBMS.KWD_UNKNOWN);
        tableinfo.tableName = StringWrapper.unwrapString(((StringWrapper)(Logic.accessBinaryValue(relation, RDBMS.SGT_RDBMS_RELATION_TABLE))));
        tableinfo.columnIndex = KeyValueMap.newKeyValueMap();
        { int i = Stella.NULL_INTEGER;
          int iter000 = 1;
          int upperBound000 = arity;
          boolean unboundedP000 = upperBound000 == Stella.NULL_INTEGER;
          Symbol var = null;
          Cons iter001 = relation.ioVariableNames.theConsList;
          Cons collect000 = null;

          for (;(unboundedP000 ||
                    (iter000 <= upperBound000)) &&
                    (!(iter001 == Stella.NIL)); iter000 = iter000 + 1, iter001 = iter001.rest) {
            i = iter000;
            var = ((Symbol)(iter001.value));
            { RelationColumnInfo self002 = RelationColumnInfo.newRelationColumnInfo();

              self002.tableInfo = tableinfo;
              columninfo = self002;
            }
            columninfo.columnName = StringWrapper.unwrapString(RDBMS.getTableColumnName(relation, i));
            columninfo.columnVariable = var;
            columninfo.columnIndex = i - 1;
            columninfo.columnType = ((NamedDescription)(edu.isi.powerloom.PLI.getNthDomain(relation, i - 1)));
            columninfo.moduleName = StringWrapper.unwrapString(RDBMS.getTableColumnModuleName(relation, i));
            columninfo.moduleReference = StringWrapper.unwrapString(RDBMS.getTableColumnModuleReference(relation, i));
            tableinfo.columnIndex.insertAt(StringWrapper.wrapString(columninfo.columnName), columninfo);
            tableinfo.columnIndex.insertAt(var, columninfo);
            tableinfo.columnIndex.insertAt(StringWrapper.wrapString(var.symbolName), columninfo);
            if (collect000 == null) {
              {
                collect000 = Cons.cons(columninfo, Stella.NIL);
                if (columns == Stella.NIL) {
                  columns = collect000;
                }
                else {
                  Cons.addConsToEndOfConsList(columns, collect000);
                }
              }
            }
            else {
              {
                collect000.rest = Cons.cons(columninfo, Stella.NIL);
                collect000 = collect000.rest;
              }
            }
          }
        }
        tableinfo.columnList = columns;
        tableinfo.columnVector = Logic.consToVector(columns);
        { RelationColumnInfo column = null;
          Cons iter002 = tableinfo.columnList;

          for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) {
            column = ((RelationColumnInfo)(iter002.value));
            if (column.moduleName != null) {
              column.moduleLocalP = true;
              column.module = Stella.getStellaModule(column.moduleName, false);
              if (column.module == null) {
                Stella.STANDARD_WARNING.nativeStream.println("Warning: RDBMS: Column module `" + column.moduleName + "' for column `" + column.columnName + "' on relation `" + relation + "' is not defined; ignoring it...");
                column.module = defaultmodule;
              }
            }
            else if (column.moduleReference != null) {
              column.moduleLocalP = true;
              column.moduleReferenceColumn = ((RelationColumnInfo)(tableinfo.columnIndex.lookup(StringWrapper.wrapString(column.moduleReference))));
            }
            else {
              column.module = defaultmodule;
            }
          }
        }
        return (tableinfo);
      }
    }
  }