Sunday, January 6, 2008

TreeView Database Design

We recently come cross a project where we need to design a training course pathway. To be able to finish the final course, one need to do all the prerequisites of this course first. The prerequisites can have options which means you can either finish one or another to be eligible for the final course. There coule be prerequisites under prerequisites as well. So this is a recursive datasource.
We came up with a solution using asp.net treeview control. The most difficult part of this job is the database design. Here is our design:

The main relationships are:

  • One course can be many nodes
  • One node can have many options
  • One option can have many nodes

In order to populate the hierarchical data structure for the treeview, we need to

  • Step1: Start with the top level nodes, then find their options
  • Step2: Find nodes under these options
  • Step3: Find options of the nodes in step2
  • Step4: Keep searching recursively till no nodes are found

blog comments powered by Disqus