---
name: "DBIx::DBSchema::ForeignKey"
section: "3pm"
platform: "linux"
package: "libdbix-dbschema-perl"
version: "0.47-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/DBIx::DBSchema::ForeignKey"
---

# DBIx::DBSchema::ForeignKey(3pm)

Foreign key objects

## NAME

DBIx::DBSchema::ForeignKey - Foreign key objects

## SYNOPSIS

```
  use DBIx::DBSchema::ForeignKey;
  $foreign_key = new DBIx::DBSchema::ForeignKey (
    { 'columns' => [ 'column_name' ],
      'table'   => 'foreign_table',
    }
  );
  $foreign_key = new DBIx::DBSchema::ForeignKey (
    {
      'constraint' => 'constraint_name',
      'columns'    => [ 'column_name', 'column2' ],
      'table'      => 'foreign_table',
      'references' => [ 'foreign_column', 'foreign_column2' ],
      'match'      => 'MATCH FULL', # or MATCH SIMPLE
      'on_delete'  => 'NO ACTION', # on clauses: NO ACTION / RESTRICT /
      'on_update'  => 'RESTRICT',  #           CASCADE / SET NULL / SET DEFAULT
    }
  );
```

## DESCRIPTION

DBIx::DBSchema::ForeignKey objects represent a foreign key.

## METHODS

- new HASHREF \| OPTION, VALUE, ...

  Creates a new DBIx::DBschema::ForeignKey object.

  Accepts either a hashref or a list of options and values.

  Options are:

  - constraint - constraint name

    - columns - List reference of column names

    - table - Foreign table name

    - references - List reference of column names in foreign table

    - match -

    - on\_delete -

    - on\_update -

    - constraint \[ CONSTRAINT\_NAME \]

  Returns or sets the constraint name

- table \[ TABLE\_NAME \]

  Returns or sets the foreign table name

- columns \[ LISTREF \]

  Returns or sets the columns.

- columns\_sql

  Returns a comma-joined list of columns, suitable for an SQL statement.

- references \[ LISTREF \]

  Returns or sets the referenced columns.

- references\_sql

  Returns a comma-joined list of referenced columns, suitable for an SQL statement.

- match \[ TABLE\_NAME \]

  Returns or sets the MATCH clause

- on\_delete \[ ACTION \]

  Returns or sets the ON DELETE clause

- on\_update \[ ACTION \]

  Returns or sets the ON UPDATE clause

- sql\_foreign\_key

  Returns an SQL FOREIGN KEY statement.

- cmp OTHER\_INDEX\_OBJECT

  Compares this object to another supplied object.  Returns true if they are have the same table, columns and references.

## AUTHOR

Ivan Kohler \<ivan-dbix-dbschema@420.am\>

Copyright (c) 2013 Freeside Internet Services, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

## BUGS

Should give in and Mo or Moo.

## SEE ALSO

DBIx::DBSchema::Table, DBIx::DBSchema, DBI
