Is there a nomenclature standard for table index names in Mysql?

Asked

Viewed 639 times

2

It seems simple this question, but wanted to know how to set a pattern. Usually using the Mysql Workbench a default is set automatically, as in the example below:

fk_tabela1_tabela2_idx

Note: I am using Laravel that has nomenclature patterns for tables, but I could not find anything about indexes.

  • 1

    If you’re willing to do it on Laravel in the migration?

  • I work directly in the database, I’m not using Migration in that project in question.

  • 1

    Carlos at Workbench I can write one for indices fields! he has this feature.

  • Do you use any convention to define your indices?

  • 1

    I usually put for indices the way you did in the description of the question, but there is no pattern to follow and if there is I really do not know. Maybe you have someone from DBA to say something.

1 answer

1


To illustrate, say you have a table posts which has as a foreign key the id of a user in the field user_id. Your foreign key would be:

posts_user_id_foreign // [table]_[columns]_[indextype]

You can find more about this in class Illuminate\Database\Schema\Blueprint at that link, look for the method foreign(), on line 395.

  • if you have solved your problem, do not forget to mark as solution.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.