Define relation between tables

Relations between tables can by dragging the field of one table, and dropping it on the corresponding field in the related table. For example, in the departments and employees tables, you would click on the foreign key A foreign key is a field from a database table that refers to (or targets) a specific key, usually the primary key, in another table. This is a convenient way of logically linking information from related tables in the same database. For instance, a table that stores information about products can contain a foreign key that references the primary key field in a table that stores manufacturers. This way, each product has an associated manufacturer – its associated foreign key points to the unique identifier of the manufacturer. Please note that the foreign key is not unique, but the referenced field (the primary key in the referenced table) usually is. column, drag it to the departments table, and drop it on top of the id_dep. See the following image for details:

 

Afterwards, the relation In a database, tables are usually linked together in a logical way. A link between two tables is called a "relation". A relation always involves two tables ad two columns from them (one can create a relation between a table and itself for representing a tree like structure) should look similar to the image below:

 

When the relation is created a line and an arrow will appear between the two tables. The arrow represents the direction of the JOIN SQL statement - LEFT JOIN, RIGHT JOIN, or INNER JOIN (no arrow).

There is also the possibility to create a relation between a table and a copy of itself (self-foreign key). To create a self-foreign key relationship, just right click on the table and select the Duplicate option. Once the copy is created, use the same drag and drop process between the table and it's duplicate copy. For a definition of the self-foreign key principle, check out the Glossary tab.

Related Topics