Fey::FK - Represents a foreign key


version 0.43


  my $fk = Fey::FK->new( source => $user_id_from_user_table,
                         target => $user_id_from_department_table,


This class represents a foreign key, connecting one or more columns in one table to columns in another table.


This class provides the following methods:


This method constructs a new Fey::FK object. It takes the following parameters:

  • source_columns - required

  • target_columns - required

    These parameters must be either a single Fey::Column object or an array reference containing one or more column objects.

    The number of columns for the source and target must be the same.



Returns the appropriate Fey::Table object.



Returns the appropriate list of Fey::Column objects as an array reference.


Returns an array reference. Each element of this reference is in turn a two-element array reference of Fey::Column objects, one from the source table and one from the target.

$fk->has_tables( $table1, $table2 )

This method returns true if the foreign key includes both of the specified tables. The tables can be specified by name or as Fey::Table objects.


Given a Fey::Column object, this method returns true if the foreign key includes the specified column.


This returns true if the the source and target tables for the foreign key are the same table.


Returns a stringified representation of the foreign key in a pretty layout something like this:

  User      Message
  -------   -------
  user_id   user_id


See Fey for details on how to report bugs.


Dave Rolsky <>


This software is Copyright (c) 2011 - 2015 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)