Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Storing a tree of objects in a column as a string or binary form.

Posted on 2004-08-06
5
Medium Priority
?
236 Views
Last Modified: 2010-04-15
I am wondering which is a better way of storing a tree of objects in DB.
I have requirement like this
and i have 2 options
1. convert the tree into xml and store it as a string or
2. Serialize it and store it in binary form.
Anny suggestions please.

Thanks.
0
Comment
Question by:pathurun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11739932
why not just serialize it to XML ?

http://www.topxml.com/xmlserializer/serializer.PDF
0
 
LVL 5

Expert Comment

by:jjacksn
ID: 11742578
It depends on what you are trying to do.  binary storage will be much smaller, but unreadable outside of your program.  You will be able to read XML outside of your program, and, in general, I would recommend using XML unless there is a reason not to.
0
 
LVL 4

Expert Comment

by:Jigit
ID: 11745685
Another option is to store it in a table with the following schema:

ID | Parent ID | Data
0  | null         | root data
1  | 0            | first child data
2 |  0            | second child data
0
 
LVL 2

Expert Comment

by:jrberg
ID: 11764465
I agree with Jigit.  It's always best IMO to store data in a database so that it could be read in by other applications and sources and understood and serialization in binary would take that away from you.  Ofcourse with XML serialization this is somewhat true also because some of the state information is going to be stored as nested garbeled text in the XML.  I would just create a method for saving data and retreiving data and saving it in the format Jigit shows.

-- Jerry
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 2000 total points
ID: 11764611
whether or not you want to use that format depends completely on what the data is ...

for instance if this data is a users customized web menu this may very well be the wrong way of doing it, it would be much more difficult to maintain especially if the data has no use outside the context of dealing with the menu ...

Another good example of when to not use this would be if you don't know the types of data being placed in i.e. the format is dynamic (users can define their own types etc). Again very easy to do with XML very difficult to do in a database.

Another reason for possibly storing in XML would be if speed is a huge concern ... when you store data in a table as above you need to query multiple times as you build in order to get children (or you need to suck back the whole table and use rowfilters). this also holds true if a database query is considerred "expensive" in your system (i.e. remote or slow database etc)

0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question