Creating References
To create a reference between two tables, click on the
icon on the Palette toolbar. Your mouse cursor will change its appearance. Then click on the table (a referencing table) that will have foreign key and then click on the second table (referenced table) whose constraint (e.g. primary key) will be referred by the new foreign key.
To create a self reference (it links a columns on the same table), click on the
icon on the Palette toolbar. Then click the table two times.
To create N:M references, refer to Creating a Many-to-Many Reference.
Reference Creation in Details
On reference creation, Database Designer for MySQL performs the following actions:
-
Creates new column(s) in the referencing table, their parameters (name, data type) will be copied from the primary key constraint of the referenced table. If the referencing table already has column(s) analogous to the primary key(s) of the referenced table, this column(s) will be used as foreign-key column(s).
-
If there is no primary key or unique constraints in the referenced table, a standard primary key column will be created in the referenced table.
-
Creates index for the foreign-key column(s) in the
referencing table. This is neccessary action for the MySQL InnoDB table type. You can disable this action in the
Database Options.
-
Creates foreign key constraint in the referencing table that refers to the referenced table primary key(s).
See the diagram database options to find out more about disabling some of above actions.
See the Notation topic to find out more about reference symbol on the diagram.
Diagram: Notation | Database Options | Creating a Many-to-Many Reference
Diagram Objects: Reference Editor
©2005 MicroOLAP Technologies LTD. All Rights Reserved. All trademarks are the sole property of their respective owners.