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

Asked

Viewed 2,870 times

4

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

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

And also:

The main Primary key is named like this: "name_da_tabela_id". Examples: "usuario_id", "evento_id". The remaining columns should be named with the first three letters of the table name, and the field name. Example: "usu_name", "usu_addressee".

It turns out we’re going to adopt the use of frameworks like Laravel and Cakephp on the systems, and they have a default nomenclature for table and column names that I wanted to take advantage of.

Question

Is it worth following this way, and entering the table name manually into the frameworks classes, or are these not good practices? What are the best practices, based on examples of literature and case studies?

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

  • 2

    I’m taking this discussion to the goal: http://meta.answall.com/questions/482 @Betasystems-Rodrigoduarte

2 answers

10


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

In your case, if Laravel and Cakephp have a Nomeclature format for tables and columns, changing this pattern to something custom of yours will generate extra work (Every time you use an automatic framework, you have to remember to go and configure something manually). And this is a potential source of bugs.

If your company’s standard is even inflexible, or justified for some other reason (e.g., legacy code amount, reuse of tables/columns in other codes), then you will have no choice but to record this change to the default framework.

4

Look,

I follow Microsoft’s "best practices":

Tables

  1. Pluralized
  2. First uppercase letter for each word (Camelcase)
  3. Without _ or any other symbol

Campos

  1. Table name added to word "Id" (e.g.: Table name)
  2. Uppercase first letter for each word (Camelcase)

These are the practices that I use, being good or not, for me it makes it much easier and it is very readable everything, code, base and similar.

This is a Microsoft manual, where is much of what I said and more. In this manual, they took the pluralization.

Another thing, about what you said about frameworks, Laravel and Cakephp, and I forgot to comment is that it’s easier for you to follow the pattern than to change it, but if the company asks, or you think their pattern makes it difficult to read the project/bank, you’d better adopt another standard, what best suits you or your company.


Another interesting article: http://architects.dzone.com/articles/20-database-design-best

  • Do you have any reference to this material?

  • Dude, not on hands, but I’ll look around and update here.

  • 2

    I think I know why they took away the pluralization... It gives a darn manpower, and when location enters the middle the thing gets even worse. I remember Ruby on Rails (which uses Coc), there was a bug in the pluralization method, and they had to keep the bug because fixing it would break several legacy codes! I’ll tell you, the main reason I never got too close to the Ror was this convention - and its inflexibility to get around.

  • So, no, no, no. NET, who uses this pluralization, by default, is the Entity Framework, if you do by Codefirst and do not set as false the pluralization option, it will create all tables with pluralization, of course it works perfectly in English; but I can’t see many problems with SQL and . NET, but I understand the point you addressed.

Browser other questions tagged

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