/**
* Return whether the given foreign key is unique.
*/
public boolean isUnique(ForeignKey fk) {
PrimaryKey pk = fk.getTable().getPrimaryKey();
if (pk != null && pk.columnsMatch(fk.getColumns()))
return true;
Index[] idx = fk.getTable().getIndexes();
for (int i = 0; i < idx.length; i++)
if (idx[i].isUnique() && idx[i].columnsMatch(fk.getColumns()))
return true;