SQL Server - Algorithm Finding Shortest Path in SQL Server database

Asked By Venkat K on 27-Feb-13 05:17 AM
In out database we have a tree which has some exams... the candidates has many possible ways to complete the certifications.

ex:
Level1 -   Software Engineer
  ExamList1: (2)
  Level2    Exam1
  Level2    Exam2
  Level2     Exam3

ExamList2: (1)
  Level2  Exam4
  Level2  Exam5

In the above tree the candidate need to write (Exam1 and Exam2) (OR) Exam4 to become as software engineer. because the met value is (2) fro ExamList1 and (1) for ExamList2.

Now My Question is:
I need to find the shortest path to complete the Software Engineer certificate. (here the ExamList2 since 1 exam is enough to complete). In real time we have more number of levels.

How can i construct the algorithm for calculating the shortest path.
Any suggestions / links are welcome.

Thanks

Robbe Morris replied to Venkat K on 27-Feb-13 08:54 AM
Inside SQL Server, you might want to look at SQL Server Common Table Expressions:

http://www.eggheadcafe.com/articles/sql_server_recursion_with_clause.asp

But, in my view, this task is much better suited in a programming language like C# or VB.NET.

Venkat K replied to Robbe Morris on 28-Feb-13 03:38 AM
Thanks a lot for the reply Robbie, outs is most DB oriented application and our client requested this to be implemented in Relational Database. i will look into that article.