private void getImportedKeys(Connection connection, String table) throws SQLException {
    if (!this.importedKeys.containsKey(table)) {

      Map<String, String> importedKeys = new HashMap<>();
      this.importedKeys.put(table, importedKeys);

      DatabaseMetaData metaData = connection.getMetaData();
      ResultSet rs = null;
      try {
        rs = metaData.getImportedKeys(connection.getCatalog(), null, table);

        while (rs.next()) {

          String pkPropertyId = PropertyHelper.getPropertyId(
                  rs.getString("PKTABLE_NAME"), rs.getString("PKCOLUMN_NAME"));

          String fkPropertyId = PropertyHelper.getPropertyId(
                  rs.getString("FKTABLE_NAME"), rs.getString("FKCOLUMN_NAME"));

          importedKeys.put(pkPropertyId, fkPropertyId);
        }
      } finally {
        if (rs != null) {
          rs.close();
        }
      }
    }
  }
Lazily populate the imported key mappings for the given table.

@param connection the connection to use to obtain the database meta data
@param table      the table
@throws SQLException thrown if the meta data for the given connection cannot be obtained
ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java