Should I adopt the naming pattern of my framework or team legacy?

4

Here in the company, everyone follows a pattern in the projects:

  

All tables must be named in the singular. Examples: "user", "event", "category".

And also:

  

The primary primary key is named "id_table_id". Examples: "user_id", "event_id". The remaining columns must be named with the first three letters of the table name, and the field name. Example: "user_name", "user_name".

It turns out that we're going to adopt frameworks like Laravel and CakePHP on systems, and they have a default naming convention for tables and column names that I wanted to take advantage of.

Question

Is it worth to follow this way, and insert the name of the tables manually in the framework classes, or are these not good practices? What good practices, based on the literature examples and case studies ?

This database will be modeled for a new system, thus not depending on compatibility with other systems.

    
asked by anonymous 15.01.2014 / 17:32

2 answers

10

If a given framework has a standard, following this pattern will always give you less work than adapting it to some reality.

In your case, if Laravel and CakePHP have a table and column name format, changing this pattern to something custom your will generate extra work (every time you use something automatic from the framework, you have to remember go configure something manually). And this is a potential source of bugs.

If your company standard is either inflexible, or otherwise justified (eg, legacy code quantity, reuse of tables / columns in other codes), then you have no choice but register this change in default of the framework.

    
15.01.2014 / 17:58
4

Look,

I follow Microsoft's "best practices":

Tables

  • Pluralized
  • First letter capitalization for each word (CamelCase)
  • Without _ or any other symbol
  • Fields

  • Name of the table added to the word "Id" (eg, TableId)
  • First letter for each word (CamelCase)
  • These are the practices I use, whether they are good or not, for me it makes it much easier and everything readable, code, base and the like.

    This is a Microsoft manual , where there is a good deal of what I said and more. In this manual, they took pluralization.

    Another thing, about what you said of the frameworks, Laravel and CakePHP, and I forgot to comment is that it is easier for you to follow the pattern than to change it, but if the company asks, or do you think the default making it difficult to read the project / bank, you'd better adopt another standard, which suits you or your company.

    Another interesting article: link

        
    15.01.2014 / 17:57