2
I am modeling a database which services belong to a category (used in most cases). Currently, categories are defined in the service table itself with a 'level' flag where I say whether that record is 'parent' or 'child'.
In this case, this would be the correct form of modeling of service categories?
Current example:
codigo | cod_pai | nivel | nome
0001 | 0001 | pai | Acessórios
0002 | 0001 | filho | Item de Acessórios
0003 | 0001 | filho | Item de Acessórios
0004 | 0001 | filho | Item de Acessórios
0005 | 0005 | pai | Mesa e Banho
0006 | 0005 | filho | Item de Mesa e Banho
0007 | 0005 | filho | Item de Mesa e Banho
Yes, with this information it is possible to find the son, father, grandfather and so on. The main thing is to make a good algorithm to recover the necessary information.
– denes bastos