Re: [bdbxml] Indexes and Booleans

George Feinberg <[email protected]> Thu, 22 Sep 2005 17:38:26 -0400
Newsgroups gmane.comp.db.dbxml.general
Message-ID <[email protected]>
> I have a node in my xml document that holds boolean data.  The  
> value for this node will either by "true" or it will be empty (the  
> node will exist, but will have no content).  I would like to put an  
> index on this node.  I have two questions about how I should set up  
> this index:
>
> (1) Should this be a KEY_EQUALITY type or a KEY_PRESENCE type?  I  
> didn't know if the node existed, but was empty, whether that would  
> be considered "present" or not.  I assume if it's KEY_PRESENCE,  
> that the syntax (question #2) does not matter so much.

It should be KEY_EQUALITY.  Presence refers to the presence of the node,
not the text value within it.

>
> (2) Is the value of "true" or empty satisfactory to support a  
> syntax of XmlValue.BOOLEAN, or should I just make this a STRING?

"true" and "false" are valid values for boolean, but if you want to  
use "true" for true, and
an empty element for false, you should use a string.
So the index should be this type:
     node-element-equality-string

The question arises, what kind of lookups do you expect to perform that
can take advantage of this index?
An actual node value for "false" may end up being more helpful than an
empty element.

Regards,

George