Schema

Dave Peticolas dave@krondo.com
Tue, 12 Dec 2000 14:33:55 -0800


David Merrill writes:
> On Tue, Dec 12, 2000 at 04:06:48PM -0600, Bill Gribble wrote:
> > On Tue, Dec 12, 2000 at 04:53:51PM -0500, David Merrill wrote:
> > > iow, what is a "suitable rational representation"?
> > 
> > A gnc_numeric data structure; 64 bit int for each of numerator and
> > denominator.
> > 
> > > Why "d"amount?
> > 
> > Figuring that out is archaeology at this point :)
> 
> :-)
> 
> This is the time to name it more appropriately. Any suggestions on
> something a bit more meaningful than 'damount'?

I think 'quantity' was suggested, and seems appropriate. What
do others think?


> I believe I understand the rationale for using the rational number
> notation. It maintains absolute accuracy when dealing with numbers
> like 2/3 which would be rounded if stored in a float. But there is no
> gnc_numeric data type in a database, so I have to either store it as a
> text field as "2/3" or in two integer fields as 2 and 3. Either one
> works just fine, but it's easier to ensure data integrity at the
> database level by working with two integers. You only have to ensure
> there are two non-zero numbers and you have valid data. Testing a
> string for validity would be more difficult and I'd have to write my
> own routine to do the testing.

Yes, if possible, we should store numbers as 64-bit ints. It is also
possible that in the db we can just dispense with the denominators
in splits all together. This is something we need to design carefully,
as some engine assumptions may need to be changed (more on that below).


> > > What is the difference between a cleared balance and a reconciled
> > > balance? You typically don't know whether a transaction has cleared
> > > until you reconcile. Or, is that changing now that we have such
> > > creatures as downloadable updates from your bank?
> > 
> > Clearing and reconciling are different things.  You need to have
> > separate totals.
> 
> What is the difference? Cleared means it has cleared the bank, and
> reconciled means you have reconciled your account with your statement,
> right?

Right, that's the difference. Many people (including myself) don't
bother going through the cleared stage, it's easier just to wait
for your statement. But you can use cleared if you want.


> Sorry I'm asking so many questions, but I am not assuming my reading
> of the code is correct.

No worries, ask away!


> In the db, *both* the account and the transaction can own a split. A
> split refers to its parent transaction *and* its parent account
> (parent in db terms, meaning they have an entity relationship defined
> by a foreign key).

In fact, currently GnuCash allows splits without parent accounts. This
is something we should probably start disallowing. The problem is, a
parent Account provides the 'meaning' of the damount and value fields
by providing the currency they are interpreted in.

dave