The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Object and Relational Heirarchies

Hello-

I have a handful of project right now that all involve heirarchical data. I need to be able to represent the heirarchy in both my object model and in my database. Individually, these are pretty easy problems. My question is what the best way is to do the mapping of the data stored in my object model heirarchy (i.e., with references) to how it is stored in the database (e.g., adjacency lists, path enumeration, nested sets, etc.). Ideally, I'd like to use a OR mapper like nHibernate.

Does anyone have some guidance on good patterns, potential pitfalls, online articles, or sample code that I could apply to this problem?

Regards-
    Eric
Eric Marthinsen Send private email
Wednesday, March 15, 2006
 
 
If I were you I'd consider getting "Joe Celko's Trees and Hierarchies in SQL for Smarties" from Amazon or another bookseller.

Caveat: I did not read it, but I have read another book in the same series (it included a chapter on nested sets for trees) and I think that Celko's knows his stuff and is probably the more authoritative source on this.
Paolo Marino Send private email
Thursday, March 16, 2006
 
 
Can you say more about how you plan to use the data?  For example, are you going to load the hierarchy up once at the beginning of a session, modify it a bit, and then commit the changes back to the DB?  Or maybe you need to do complicated traversals of the structure? Can the hierarchy items be shared between multiple hierarchies? Etc.

Obviously, the simplest thing to do would be to just use "parent" pointers in the child nodes to capture the structure, but that's rarely the best choice for certain kinds of application.  Tell us some more...
Marius Send private email
Thursday, March 16, 2006
 
 
Paolo-

Yes, I already have and have read that book. It's good, but only talks about the relational side of things.

Regards-
    Eric
Eric Marthinsen Send private email
Thursday, March 16, 2006
 
 
Marius-

I'm going to be representing small heirarchies of files and directories. The items in each heirarchy won't change often and won't share items with other heirarchies. Some of the common operations will be generating an XML represetation of the heirarchy, determining total size of a node and its children, and retrieving details of an individual node.

Regards-
    Eric
Eric Marthinsen Send private email
Thursday, March 16, 2006
 
 
How does Windows do it for the file system? Anybody know?
couldn't be arsed to think of a witty posting name
Saturday, March 25, 2006
 
 
The Windows file system doesn't use a relational database. It's an actual hierarchical store.
Chris Tavares Send private email
Tuesday, March 28, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz