1

I had a elements hierarchy above structure. Hierarchy structure

In this hierarchy of the elements insert into the my db like below image. table structure

  • In this table elements are having separate elementid and label of the element.
  • Connectors will connect the two elements and that's having the separate id and start point is source and end point is target.
  • The source and target points are having the elementid which is connected to start and end point.

I will get the data from the above mentioned table and inserted into the elementmapping table. As like below mentioned table.

enter image description here

Note: The hierarchy of the elements level dynamically increasing at any level.

Thanks in advance.

  • What version of MySQL are you using? – Rwd Apr 26 '20 at 08:32
  • I am using version of MySQL is 5.5.5-10.1.38-MariaDB. @Rwd – Balaji Sekar Apr 26 '20 at 08:53
  • In that case I would suggest looking at https://github.com/lazychaser/laravel-nestedset – Rwd Apr 26 '20 at 09:17
  • A nested set does not seem to be an option if a child can have two parents (as with id 12). I'd suggest a look at [How to create a MySQL hierarchical recursive query](https://stackoverflow.com/q/20215744), which is a pretty much complete overview of what you can do. Pick some code or different data model that fits your requirements (MySQL < 8, unlimited depths, ...), try to implement it, ask (with the code you tried) if you run into troubles (which you probably will). Just to emphasize: without MySQL 8, you most likely have to live with some restrictions, pick those that don't matter for you. – Solarflare Apr 26 '20 at 09:36

0 Answers0