It is very difficult for me to design the database because it requires a lot of recursion. I really can't use XML because it is just not practical for scalability and the amount of data I need to store. Do you guys know of a database that can be used to store hierarchical data?
views:
71answers:
5If your open to NoSQL, then I'd recommend MongoDB. It is document oriented so your not tied down to a fixed schema. It is also very scalable and performant. There are a lot of good OOP like things in it. For instance, a document can contain embedded documents so that if your database is already designed as XML, it will be mostly trivial to store in MongoDB
SQL Server also allows you to store XML files in single fields, and then easily parse specific elements/attributes from them via queries
SQL Server 2008 has the HierarchyId data type. It's specifically designed for this task. Proper indexing and keys will give you fast access to data in both depth-first and breadth-first searches.
Oracle easily allows hierarchy queries with the CONNECT BY syntax
You can have a self referential table like:
Part
part_id
parent_part_id
or a couple of tables like:
Organization
org_id
name
org_relation
org_id1
org_id2