3

I have search the internet of a way to store many to many hierarchical data in sql, but sql dosent seems to be verry optimised for that type of data. I want my data to be stored this way becurse i need it to be flexible. I dont know if iam storing 1 or 100 feilds hierarchically.

Requirements: The data also needs to be searchable. Reading the data need to be fast.

This is the solution i have found: http://en.wikipedia.org/wiki/Nested_set_model but it will make my table verry large and all fields will be in text even when i store a number or bolian.

Is there alternativs to this model? Do i have to go for a No-sql database? Is there any trends on wich database model i should use? Wich solutions are beeng used in companys that need this sort of storrage?

Looking forward hearing from you.

Markus Malkusch
  • 7,738
  • 2
  • 38
  • 67
christian
  • 57
  • 5
  • You need to give a specific example of what you want to store and how you want to use it. Two tables, nodes (nested set) and fields (unique fields), sounds like what you want. – AD7six Mar 27 '14 at 06:41

1 Answers1

1

sql dosent seems to be verry optimised for that type of data.

And there you gave yourself the answer: The best way would be to go to a DBS which is optimized for graphs.

But if for some reason you insist to stay in relation land, there are some techniques to store graph structures.

Community
  • 1
  • 1
Markus Malkusch
  • 7,738
  • 2
  • 38
  • 67
  • In every aspect! OP is asking clearly about the best way to store a graph. IMO it's a perfect valid answer to point away from relational DBS. – Markus Malkusch Mar 27 '14 at 06:57
  • I doubt using a graph db on such a (implied) trivial amount of data is worth it. How about the learning curve aspect, and the its not available on my host aspect? Note there are [many more than 2/3 options on storing hierarchical data in an rdbms](http://stackoverflow.com/questions/4048151/what-are-the-options-for-storing-hierarchical-data-in-a-relational-database), and they don't have to be complex e.g. materialized-path is easy to understand/debug/Implement. +1 – AD7six Mar 27 '14 at 06:57
  • 1
    @AD7six your link is a great answer for the options. Plus I agree with the materialized-path. I wasn't aware of the name, but that's what I meant by "path field". I'll upgrade my answer plus add that link. – Markus Malkusch Mar 27 '14 at 07:00
  • The reason Iam asking about a solution or a sql database is mainly that i do not know what enviroments this database is going to run in. So to provide a solution that works on 80 % of the servers out there is a big plus. There isnt many server providers that dosent support sql databases as part of there hosting plans. But maby the server provider has changed that and now offers other database alternativs. If so i could go for a dbs that are optimized for graphs. But i see that the alternativs arent many in relation land, maby its good enaugh. – christian Mar 27 '14 at 12:00