Answer the question
In order to leave comments, you need to log in
SQL: how to organize the dependency of elements that are in the same table?
Good day, Toaster. There is a certain table with disciplines, to study these disciplines you need to study other disciplines from the same table. How to organize a table of dependencies with these disciplines?
simple table:
id, name
Answer the question
In order to leave comments, you need to log in
id, parent_id, name
in parent_id write the id of the discipline you want to study.
An additional dependency table is not the most elegant solution. It will be much more beautiful to create a hierarchy.
Remember how all the SQL textbooks give as an example a table of employees indicating which of them is whose manager?
And here is another link to the topic: Hierarchical (recursive) queries , they tell you how to deal with such tables
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question