Cursussen/Courses Codesnippets     Top 
MySQL workbench - EER diagram relations


1. Relationships
After you have filled in all other entities (tables), you can indicate the relationships between the entities (tables).


2. Add relation
You choose the right button in the button bar on the left and click on the entities to create a relationship. The order of clicks determines which table the foreign key is included in.


3. 1-on-1 relationship
The foreign key is added to the table you click on first. In the “Relationship” tab you can enter additional information about the relationship. In the tab “Foreign Key” you can indicate the cardinality and optionality of the relation. You can reach these tabs by double clicking on the line of the relation.


4. 1-to-many relationship
The many-side is indicated by the entity (table) you click on first. In the “Relationship” tab section “Foreign Key” you can check or uncheck the optionality (“Mandatory”). The foreign key is added to the many side.


5. Many-to-many relationship
In a many-to-many relationship, a new entity (table) is added. This entity has as attributes the foreign keys that refer to the primary keys of the entities (tables) on the 1 side.


6. Save model