code: public T addForeignKey(final Connection _con,
                             final String _tableName,
                             final String _foreignKeyName,
                             final String _key,
                             final String _reference,
                             final boolean _cascade)
          throws InstallationException
      {
          final StringBuilder cmd = new StringBuilder()
                          .append("alter table ").append(_tableName).append(" ")
                          .append("add constraint ").append(_foreignKeyName).append(" ")
                          .append("foreign key(").append(_key).append(") ")
                          .append("references ").append(_reference);
          if (_cascade) {
              cmd.append(" on delete cascade");
          }
          AbstractDatabase.LOG.debug("    ..SQL> " + cmd.toString());
  
          try {
              final Statement stmt = _con.createStatement();
              try {
                  stmt.execute(cmd.toString());
              } finally {
                  stmt.close();
              }
          } catch (final SQLException e) {
              throw new InstallationException("Foreign key could not be created. SQL statement was:\n"
                              + cmd.toString(), e);
          }
          @SuppressWarnings("unchecked")
          final T ret = (T) this;
          return ret;
      }
docs: Adds a foreign key to given SQL table.
  
  @param _con SQL connection
  @param _tableName name of table for which the foreign key must be created
  @param _foreignKeyName name of foreign key to create
  @param _key key in the table (column name)
  @param _reference external reference (external table and column name)
  @param _cascade if the value in the external table is deleted, should
  this value also automatically deleted?
  @return this instance
  @throws InstallationException if foreign key could not be defined for SQL
  table