Relations

To create a new relation between two tables, click Relation on toolbar and then click parent and child tables in your diagram.

New relation

In this example, click table customer and then table order.

New relation

New relation line appears in the diagram and column customer_id is added to the child table order automatically.

New relation

By default, primary key is used for the relation. If you wish to change the primary key, select the parent table and modify primary key.
To create new alternate key, click the +Add key button in section Keys.

New relation

New key appears in the child table. Click +Add Column to Key and select a column.

Compound keys

In case you need to create compound key, for example key that should contain columns name and surname, repeat the process twice.

New relation

Final definition:

New relation

Usage

To use the compound/alternate key instead of primary key, select the relation and navigate to section Key.

New relation

Change the value in key dropdown to the new alternate key name. The tool removes the customer_id column from child table and adds there both the columns defined in the alternate key: customer_name and customer_surname.

New relation

Cardinality

Cardinality settings affect the display of relations in your diagram. Select a relation and change values in section Cardinality.

Optional child settings change the appearance of line ending to circle. And if you set cardinality to 1, the relation line will be displayed without the crows' foot graphics.

New relation

Primary foreign keys

If you set a foreign key column in a child table to primary key, color of the key changes to blue.

New relation

Referential integrity

To change referential integrity settings, select a relation and modify values in section Referential integrity.

Self relations

To create a self relation, click the Relation item on toolbar and then click one table in the diagram twice (not double click it, wait a moment before you click the same table again.)

#

 

 

Copyright: 2019 Datensen. All rights reserved.
This website is not endorsed by MongoDB, Inc.
This website uses cookies to ensure you get the best experience on our website.