D
D
Dom Alfro2022-01-18 08:52:56
SQL
Dom Alfro, 2022-01-18 08:52:56

How to correctly implement nesting in database?

Good time everyone!
There is a problem, I need to implement a tree in a table,
I need to make categories> subcategories-> subcategories (the level of subcategories is not limited)
61e654eabe665021701460.png
I surfed the Internet and found ways to implement it, but there are not enough materials for me. and it's hard to understand,
maybe someone has experience in creating such a hierarchy - where you need to implement categories with subcategories and subcategories.
I still need to do this in laravel. Perhaps there are even libraries that can solve this problem
, since I'm only at the very bottom in data, that is, simple queries like Select * from `table` well, for example.
and here it is.
I will be grateful for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2022-01-18
@mustang_shelby

(the level of subcategories is not limited)
Just for this case, once upon a time they came up with a universal contraption:
https://www.google.com/search?q=entity+attribute+value
Perhaps there are even libraries
No libraries are needed for this, but keep in mind that the amount of program code you can get is an order of magnitude larger than for the case with a clear fixed structure. Therefore, such architectures (when the level of subcategories is not limited) should be avoided whenever possible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question