Switch to: V14V13V12V11V10V9V8V7V6V5

CREATE LINK statement

This command allows to create a BINARY LINK between two tables of the database.

Syntax

v_create_binary_link
    :    CREATE [OR REPLACE] BINARY LINK [IF NOT EXISTS] 
           link_name ON TABLES ( TABLE_NAME , TABLE_NAME ) 
           AS link_type TO link_type 
           [referential_triggered_action_for_link]
           [OWNER TABLE_NAME]
 
link_type
    :    ONE | MANY | UINT
 
referential_triggered_action_for_link
    :    ON DELETE vext_referential_action_for_link
 
vext_referential_action_for_link
    :    RESTRICT | NO ACTION | CASCADE | NO CASCADE

Arguments

OR REPLACE

Recreates the Binary Link if it already exists. You can use this option to change the definition of an existing link without first dropping it.

IF NOT EXISTS

The IF NOT EXISTS option allows you supress the error message in case if such table Link exists. This makes it much easier to perform SQL dumps without interruption.

linkname

Name of link. Must be unique in the scope of Links and Tables.

ON TABLES

Specifies two tables to be linked.

Specifies how this table should be linked. Can be ONE or MANY.

ON DELETE referential_action

Specifies action to be executed for the CHILD records when a parent record is deleted. Similar to FOREIGN KEY and ObjectPtr links, but have little other set of constants, because “SET DEFAULT”, “SET NULL” have no sense for BinaryLink. And “NO CASCADE” is used as analog of “SET NULL”, i.e. do not delete child-records.

Note, that this concept works naturally for cases 1:M and M:1. But if you have a 1:1 or a M:M link, then you may need to specify explicitly the OWNER/PARENT table. See the next argument.

OWNER table_name

Specifies the table to be OWNER of link. This table also can be named the PARENT table. You need to specify it only if you have link of 1:1 or M:M type (i.e. symmetric) and you want to specify ON DELETE behavior.

Examples

CREATE BINARY LINK 
   ON TABLES person_phone(Person, Phone) 
   AS MANY TO MANY

See Also

To see how to create a Foreign Key or ObjectPtr links go to CREATE TABLE