[Mono-list] Tree data storage on BerkeleyDB

Piers Haken piersh@friskit.com
Fri, 20 Sep 2002 15:20:36 -0700


I think this is the best way since the most common use case is:

RegistryKey rk = Registry.CurrentUser.OpenSubKey
(@"Software\MyCompany\MyApplication");
int iValue = rk.GetValue ("some int");
int iValue2 = rk.GetValue ("some other int");
string strValue = rk.GetValue ("some string");
...etc...

So I would have two tables:
Keys:   (hkey, name, hkeyParent)
Values: (name, hkeyParent, type, value)

So, for the above exmple, your tables might look like this:

Keys:
	(1, "HKEY_CURRENT_USER", null)
	(2, "Software",          1)
	(3, "MyCompany",         2)
	(4, "MyApplication",     3)

Values:
	("some int",       4, REG_DWORD, 0x00000001)
	("some other int", 4, REG_DWORD, 0x00000002)
	("some string",    4, REG_SZ   , "blah")

You /could/ have different tables for the different value types, but
that would make searching and uniqueness difficult. It's probably best
to just store a BLOB (if that's cheap with bdb).

Remember that value names can be null (for default values).

Piers.

> -----Original Message-----
> From: Seun Osewa [mailto:osewa77@yahoo.com] 
> Sent: Friday, September 20, 2002 9:47 AM
> To: mono-list@ximian.com
> Subject: Re: [Mono-list] Tree data storage on BerkeleyDB
> 
> 
> Hi!
> 
> ANother option would be to create an equivalent of a
> (relational?) table linked unto itself in berkeleydb. 
> each "node" would contain a value and would contain a
> pointer to its parent "node".  This approach would
> probably save space for large keys.  But some
> secondary indices on the table would be needed. 
> Latest bdb versions support these.  It would be like
> creating a table in MySQL only embedded this time:
> 
> Nodes
> ---------
>  id	name	parent
>  0	LOCAL	-1(?)
>  1	Admin	0
>  2	Progs	0
>  3	Root	1
> 
> Values:
> -----------
> node_id  Value
> ----------------------
> 
> The general idea is obvious, I guess... just a
> possible alternative, though its slower as someone
> mentioned... depends on what the registry is used most
> often for.
> 
> bye!
> 
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com 
> http://lists.ximian.com/mailman/listinfo/mono-list
>