S
S
Senture2020-02-14 13:39:54
JavaScript
Senture, 2020-02-14 13:39:54

How to correctly name fields in a database?

Good day!
I read somewhere the rules for naming fields in the database, it says the following:

For example, there is a table named Nomenclature, and it has the following fields Id and Type, but they need to be named NomenclatureId and NomenclatureType.

To what extent is this the right decision?

And another question, but if the name of the field is long, for example TypeMaterialCloth, the field will have to be named as NomenclatureTypeMaterialCloth, isn't the name long?

Although it seems to me that the answer to this question would be a more thoughtful name for the field (not so long), I would like to hear your opinion!

PS Thank you all very much!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2019-06-09
@relows

const index = arr.findIndex(n => n.id === id);
if (index !== -1) {
  arr.splice(index, 1);
}

or, if a new array is needed: If the id values ​​are not unique, then the creation of a new array remains unchanged, and the modification of an existing one may look like this:
const newArr = arr.filter(n => n.id !== id);
for (let i = arr.length; i--; ) {
  if (arr[i].id === id) {
    arr.splice(i, 1);
  }
}

or like this:
arr.reduceRight((_, n, i, a) => n.id === id && a.splice(i, 1), null);

V
Vladimir Korotenko, 2020-02-14
@Senture

Look at the limitations of your database, there are allowed lengths for table names, columns, reserved words.
In general, long names are justified only in indexes and foreign keys, and it is better to name columns somehow shorter. And in joins, you can use aliases.
https://dev.mysql.com/doc/refman/8.0/en/column-cou...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question