开发者

How can I create a multi-hierarchical 'tree'? (If it can be called a tree)

开发者 https://www.devze.com 2022-12-10 00:13 出处:网络
i have a list of say courses and certificates and fun_days. These are all called objects. Every object has its requirements object_requirements. A requirement can be either one of the objects or sever

i have a list of say courses and certificates and fun_days. These are all called objects. Every object has its requirements object_requirements. A requirement can be either one of the objects or several of them.

You can take any object without object_requirements as a starting point. "Everybody is allowed to have those objects."

So it could be that:

  • Introduction_course is a starting point (no requirements)
  • Introduction_certificate can be obtained by those who have Introduction_course (this course is a requirement of this certificate)
  • Funday_swimming can be obtained by those who have a Introduction_certificate (the certificate is a requirement of the fun_day).

Is there a way to create a visual representation of the hierarchical or somewhat structured-flow of this system? The example is fairly simple, but multiple requirements anywhere in the 'tree' should be possible.

This is how I store the requirements:

TABLE: OBJECT_REQUIREMENT
 OBJECTTYPE                (pk)
 OBJECTID                  (pk)
 REQUIREMENT_OBJECTTYPE    (pk)
 REQUIREMENT_OBJECTID      (pk)

TABLE: COURSE
 OBJECTID                  (pk)
 OBJECTTYPE                       // value is always [1] for course

TABLE: CERTIFICATE
 OBJECTID                  (pk)
 OBJECTTYPE                       // value is always [2] for certificate

TABLE: FUN_DAY
 OBJECTID                  (pk)
 OBJECTTYPE                       // value i开发者_如何学编程s always [3] for fun_day

Oh and I use PHP and MySQL. But any piece of software which could generate these visual representations would be more than welcome also!


You might consider something like a directed graph, to which this previous SO question might be useful:

How to do directed graph drawing in PHP?


You can use the <li> tag, so:

  • Introduction_course
    • Introduction_certificate
      • funday_swimming
    • Another certificate

If you are trying to show it in html.

If you want something that is more graphical, you can use svg files or canvas tags (in html5) in order to draw the graph, or, just use lib_gd to draw a bitmap, and make it into an imagemap, if needed.

0

精彩评论

暂无评论...
验证码 换一张
取 消