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.

Reasonable amount of redundant data

What is considered a reasonable amount of redundancy?
I inherited a data model, where a tree structure is coded with the usual ID,parentID columns, but there is also:
-path (all parent node IDs),
-level of ID,
-level of parentID
I am talking about 1000 nodes max.
You have to constantly maintain integrity of the structure updating all this stuff if something changes.
Isn't it a bit too much ?
Another one:
two same tables in two different DBs, but
table1:
column1,
column2,
column3

table2:
column3
column1
column2
It doesn't make any sense and it is pain in the a.. to automate export-import procs. Is it just a bad design, or some idea of local genius ?
thursday
Thursday, March 09, 2006
 
 
If there are only 1k nodes, it doesn't seem like an expensive operation to climb the tree to determine depth.  (Unless each of those 1k nodes are parent-child!)

Before you can determine whether or not this information is necessary, you need to determine *if* it is being used anywhere.

If it's being used, you must maintain it *or* re-implement the corresponding getters to calculate these values when needed.  Since this could be done lazily, it may end up saving you cycles.
KC Send private email
Thursday, March 09, 2006
 
 
I have implemented a similar tree structure. I added the extra info as well.

It made reporting / querying via SQL multiple factors of ten easier and faster.

The little extra coding in the mainentance function was well worth it.
DJ
Thursday, March 09, 2006
 
 
thursday,

It's bad design.  I worked at a place that had something similar, though with far fewer nodes.  (But for that, I'd've thought you'd gotten my old job.)  Often it can be chalked up to politics; the person with the crappy design had to be listened to, for some reason that had nothing to do with the quality of his/her design skills, and now the developers are saddled with supporting this crappy design.
Kyralessa Send private email
Thursday, March 09, 2006
 
 
I suggest you to google for "Joe Celko SQL trees" to see what the alternatives are.
(Check Google Groups besides the main pages searches, because this has been extensively discussed in the groups too).

If you find the alternative interesting, Celko has a couple books on this in Amazon. A full chapter in "SQL for Smarties" and (but I never read it) a book completely devoted to tree structures in RDBMS.
Paolo Marino Send private email
Friday, March 10, 2006
 
 
Just out of curiosity, is there ever a case where level of parentID doesn't equal (level of ID) - 1 or NULL?
Rich
Saturday, March 11, 2006
 
 
Paolo:thanks for the lead
Rich: exactly, wtf...
monday
Monday, March 13, 2006
 
 

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

Other recent topics Other recent topics
 
Powered by FogBugz