michael munson wrote:
> Greetings,
> I'm a bit new to SQL and SQLite so pardon me if I ask silly questions but I 
> have run into a bit of a wall while attempting to design a database for a C++ 
> program I am attempting to write.
> 
> The needs of the database are to: represent an object oriented hierarchy of 
> any number of objects, where each object may have custom properties of 
> several different datatypes and permission bits.
> 
> The table fields that I have so far are a primary integer key (ID), text 
> representing the object's name, (NAME), and two fields "OWNER" and "PARENT" 
> which are integers representing other objects in this table.
> 
> The problem I am running into is the object hierarchy and custom properties. 
> For example: If object #1 is a parent of object #2, and #1 has a property 
> named "location" then #2 should also have that property (although the value 
> and permissions may be different from the parent).
> 
> I'm trying to see if I can do this some way I do not currently know how, 
> because the only thing I can think of is some delimited BLOB and recalculate 
> all the parent properties whenever the parent is changed which I imagine may 
> significently slow down my database.

The first thing to ask yourself here is whether or not it makes sense to
use a database.  Certainly that makes sense if you need concurrent read
and write access, but if you only need to write from one source at a
time an XML file sounds more like what you need.  It supports your need
for infinite hierarchy, and if you work without a DTD it allows setting
of any properties that you would like.  If you don't like the general
bloat of an XML file you can make use of a library like libxml2
(http://www.xmlsoft.org) which natively and transparently supports
compressed XML files.

If you're absolutely sold on the need that this be in a database, buy a
copy of Joe Selko's _SQL for Smarties_.  It covers these hierarchical
structures in great detail.  Even after implementing this kind of
structure before I wouldn't try it again without consulting Selko's book.

Clay Dowling

Reply via email to