sql backend - guid

Derek Atkins warlord at MIT.EDU
Wed Jun 17 08:27:54 EDT 2009


Hi,

bdebrabant <bdebrabant at gmail.com> writes:

> Hi,
>
> I've recently upgraded to gnucash 2.3.1, and am now using the postgresql
> backend.
> The speed has significantly improved (compared to the xml backend),
> especially while generating reports, which is really good news.
>
> I was also thinking of populating the price database directly, from a
> second database I'm maintaining.
> Hence my questions:
>
> 1) It's not really clear why guid are characters, while it could have
> been quite easy to use integers (& autoincrement)...

GUID == UUID == 128-bit number.  It's much better to encode that in
radix-32 than in decimal.

Each object needs to have a stable GUID, and the SQL and XML need to
remain equivalent.

Also, objects need to be uniquely identified regardless of type, so
autoincrement doesn't work (unless you have a single "objectID" table
that just gives you a global GUID in the DB, but that's pretty silly
when just using a real GUID is fine.

>     Also, for some tables, like the price table, I'm not sure who
> usefull a primary key on guid can be.

It's useful because lookups are usually based on GUID.

>     Wouldn't it be better to have a primary key on
> commodity/currency/date/source for instance?

No.

> 2) Would it be safe to generate guid other than by calling qof functions?
>     Any idea how to do it?

Generally, yes, it's safe, but you should make sure they are
pseudo-random.  E.g.:

  uuidgen | sed -e 's/-//g'

> Thanks,
> Baptiste

> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-user mailing list