Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Smoleniuch's avatar

Eloquent relationships and MySQL tables relationships.

Hi,

I am using a MySQL Workbench and i were trying to display my table relationships as an EER Diagram.The point is that relationships defined in laravel doesnt exists in mysql.When diagram loads there are no nodes between tables.I have check foreign keys in the workbench,they are not defined.

Relationships defined in my app works fine,but i would like to have some graphic diagram where i can easy manage/see defined relationships.

What am i doing wrong?How do you manage your table relationships?write some kind of documentation?

Thank you ,John

0 likes
3 replies
bastman69's avatar
Level 15

I guess that when creating your migration files you define the relationship by adding eg.

$table->integer('rank_id')->unsigned();

On mySql server this is just a field but enough for laravel to do its magic.

Laravel of course offers the ability to enforce referential integrity

 $table->foreign('user_id')->references('id')->on('users');

If you add foreign keys in your migration files then you will see the connections in your Entity Diagram.

Take a look:

Foreign Key Constraints https://laravel.com/docs/5.4/migrations#generating-migrations

1 like

Please or to participate in this conversation.