How to design a database for storing menu items with unlimited additions (many parents - many descendants, etc.)? There is an option to store everything in one table, there is an option in several. How to design? If the data is stored in 1 table, will there be more load on it than, say, several?
- There is no design point of view. Do both options with real data and check performance. this will be your answer to the question. several tables are more intuitive for perception. on the other hand, if there are a lot of references, I think it is better to store it in one table + else so that it constantly hangs in memory. - jmu
|
2 answers
Many parents + many descendants are hell. This is no longer a regular tree, but a full-fledged graph, and if the sql-em tree is bypassed, then the graph is not very advisable. I tried :)
My advice - discard the "many parents" at once. And store your menu in one tablet.
And read this: What are the Options for Storing Hierarchical Data in a Relational Database?
- I wouldn’t like to disappoint you, but "A Tree is a Cyclic Connected Graph." - Dex
- A tree is certainly a graph, but certainly not cyclical, but exactly the opposite. - Andrew Frolov
|
Do in one table .
|