1
Fields with the same name in different tables may cause conflict at the time of normalizar
or make some inner join
?
Examples
Supplier Table
- Field: name
- Field: surname
- Field: email
Product Table
- Field: name
- Field: delivery date
- Field: Amount
This is a very simple example with only 2 tables, but if I have around 50 tables or more, within a given project, what is the effective solution? I’ve read about some topics saying to put nome_da_tabela_nome_do_campo
, That’s one way to escape?
According to style Guides of SQL.
Tables
Use a collective or less ideally plural name. By example, (in order of preference) staff and employees.
Do not use prefixes with tbl or any other descriptive prefix or notation hungarian.
Never give a table the same name as one of your columns and vice versa.
> Avoid when possible concatenating two table names to create a relationship table name.
In place of mechanics_de_car, prefer services.
Columns
Always use names in the singular.
When possible, avoid using only id as the primary identifier of table.
Do not add a column as the same table name and vice versa.
Always use box low, except where capitalization makes sense (as in names own).
So the part that says:
Avoid when possible concatenating two table names to create the name of a relationship table.
Would be worth the same to the fields?
Yes can cause conflict, but is easily solvable, just prefix the field name with the table name. I do not see how this can have any impact on the standardisation process.
– anonimo
type, following the example given: the
tabela Fornecedor
would be:fornecedor_nome, fornecedor_sobrenome, fornecedor_email
, and thetabela Produto
:produto_nome, produto_data_de_entrega, produto_quantidade
that way?– user152996
No, I meant tableName.fieldName, every time there is some kind of conflict with the table field names involved in the command. Not in the table definition.
– anonimo