Table keys

Keys definition

To define or edit table keys, edit your table and navigate to tab Keys or change values directly in right side panel in section Keys.

A primary key exists in every table. If you wish to add new alternate key, click button + Add Key.

To add new column either to primary key or alternate key, expand the key details and click the + Add Column to Key button and then choose column name from drop down.

Example:

table customer contains two keys. A primary key and one alternate key named customer_ak_1. The alternate key contains two columns: name and surname.

mariadb keys

Keys usage

Keys are used in relations.

Whenever you create a new relation between two tables, a primary key is used for the reference and a new foreign key column is added to a child table.
Example:

primary key and foreign key

To use previously created alternate key, edit the relation by double clicking it and navigate to tab Key.

primary key

Change the value in Key drop down to the alternate key name.

alternate key

In result, the customer_id column disappears from the child table and two new colums are added to the child table instead.

alternate key and foreign key

Primary foreign key

If you check the PK (primary key) checkbox that belongs to foreign key column, the column becomes primary key and its icon color changes to blue.

primary foreign key

#

 

 

Copyright: 2019 Datensen. All rights reserved.
This website uses cookies to ensure you get the best experience on our website.