0

I had a requirement to implement dynamic hierarchy in a project. One possible solution was to use a Graph database NoSQL solution like Neo4j. What I designed in a graph implementation in RDBMS. In this solution I designed a table has a Many To Many relationship with itself. An example of this is given here. I have a table (TABLE_A) that defines different entities and another table TABLE_B that defines type of the entities, and TABLE_B has a many to many relation with it self that defines relation between different entity types. This is store in a JoinTable, TABLE_C. Similarly TABLE_A has a many to many relationship with itself to define instances of different relations defined in TABLE_C. In Java I have used only two classes to implement this structure.

Now this many to many relationship in my case is not a always a many to many relationship. Sometimes it's a one to many and at time a one to one.

Firstly, is a No SQL Graph DB more suited to my requirement than a Relational DB since the data that I'm planning to test will be in the order of Hundred Thousand records.

Secondly, If RDBMS solution is better then is there a way to include a property in the join table TABLE_C that defines the multiplicity of the relation i.e. whether it's a one to many or a many to many or a one to one relation?

Community
  • 1
  • 1
Ujjwal Pathak
  • 646
  • 12
  • 21

1 Answers1

0

Yes you can put an arbitrary number of properties on each relationship between two nodes, from none to many. And you can have different properties on the relationships too and also different relationship-types.

A tree, is a natural structure for a graph database. It can manage trees of arbitrary depths and widths.

You can insert tree data quickly, see my example here.

Finding data in a tree is easily expressed with variable length paths.

Rik did a good blog post on using such a hierarchy to manage part lists and pricees.

Michael Hunger
  • 41,339
  • 3
  • 57
  • 80