Hierarchical data - How to resolve all course dependencies in SQL

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

Stumbled upon this problem recently, and am struggling to do it in SQL. The table in question is in the form of course, then required course.

Example: Course Requirement

MATH ENG  
ENG SCI  
ENG PHYSICS  
PHYSICS BIO  

In a standard programming language, this can be done by some sort of search algorithm to get a list of dependencies (note that they can be nested as MATH DEPENDS ON ENG which depends on SCI), but I have no idea how one would do this with SQL. I tried using joins on equality, but the fact that they can be nested is throwing me off...

So if the query is MATH, then it should return ENG, SCI, PHYSICS, BIO

Answers

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/35782078/how-to-resolve-all-course-dependencies-in-sql

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils