GDA referential integrity

Mark Johnson mrj001 at shaw.ca
Thu Jan 17 12:34:01 EST 2008


Having successfully loaded my xml file into gnucash-gda, I saved it to a 
new postgresql database.  As Phil mentioned, the performance was poor.  
I have several years of data, and it took hours to save.  The save 
completed sometime during the night, so I don't know exactly how long it 
took.

I thought I'd check the referential integrity of the results.

FIRST:
I checked that for every split, a transaction existed.  I found the 
following:
gnucash_db=# select distinct tx_guid from splits except select guid from 
transactions;
             tx_guid
----------------------------------
 16097c3be93a538e66e1de61ad743b0a
(1 row)

gnucash_db=# select * from transactions where guid = 
'16097c3be93a538e66e1de61ad743b0a';
 guid | currency_guid | num | post_date | enter_date | description
------+---------------+-----+-----------+------------+-------------
(0 rows)

So I decompressed the xml file, and searched for the transaction.  I 
found the following transaction.  It looks like a scheduled transaction 
template may have found its way into the splits table.  I have many 
scheduled transactions for each month which enter estimates of my 
various bills in advance.  Neither my checking account register nor my 
telephone expense account register show this transaction.

I did find a <gnc:schedxaction version="2.0.0"> tag for the real Telus 
scheduled transaction.  Is it possible that this is some corruption in 
my xml file due to a problem with scheduled transactions, perhaps in a 
past version of gnucash?  Is this something that gnucash should have 
eliminated from my xml file?  Or is it something I should manually 
eliminate?

<gnc:transaction version="2.0.0">
  <trn:id type="guid">16097c3be93a538e66e1de61ad743b0a</trn:id>
  <trn:date-posted>
    <ts:date>2005-04-27 00:00:00 -0600</ts:date>
  </trn:date-posted>
  <trn:date-entered>
    <ts:date>2005-04-27 12:26:51 -0600</ts:date>
  </trn:date-entered>
  <trn:description>Telus</trn:description>
  <trn:splits>
    <trn:split>
      <split:id type="guid">b527916bbace3d5e0ea2a630fb8f1eb0</split:id>
      <split:reconciled-state>n</split:reconciled-state>
      <split:value>0/100000</split:value>
      <split:quantity>0/1</split:quantity>
      <split:account 
type="guid">2c60936ed64493bbac454d355225b052</split:account>
      <split:slots>
        <slot>
          <slot:key>sched-xaction</slot:key>
          <slot:value type="frame">
            <slot>
              <slot:key>credit-formula</slot:key>
              <slot:value type="string"></slot:value>
            </slot>
            <slot>
              <slot:key>account</slot:key>
              <slot:value 
type="guid">44cb47f1969bfecf5acbadd9102cd467</slot:value>
            </slot>
            <slot>
              <slot:key>debit-formula</slot:key>
              <slot:value type="string">23.91</slot:value>
            </slot>
          </slot:value>
        </slot>
      </split:slots>
    </trn:split>
    <trn:split>
      <split:id type="guid">b781fc87bdf4e0e8c56bb4d64f8b9670</split:id>
      <split:reconciled-state>n</split:reconciled-state>
      <split:value>0/100000</split:value>
      <split:quantity>0/1</split:quantity>
      <split:account 
type="guid">2c60936ed64493bbac454d355225b052</split:account>
      <split:slots>
        <slot>
          <slot:key>sched-xaction</slot:key>
          <slot:value type="frame">
            <slot>
              <slot:key>credit-formula</slot:key>
              <slot:value type="string"></slot:value>
            </slot>
            <slot>
              <slot:key>account</slot:key>
              <slot:value 
type="guid">e73d42a961c24d40abb551c3c6fae0d4</slot:value>
            </slot>
            <slot>
              <slot:key>debit-formula</slot:key>
              <slot:value type="string">1.41</slot:value>
            </slot>
          </slot:value>
        </slot>
      </split:slots>
    </trn:split>
    <trn:split>
      <split:id type="guid">354c6952020397704105d002861d3499</split:id>
      <split:reconciled-state>n</split:reconciled-state>
      <split:value>0/100000</split:value>
      <split:quantity>0/1</split:quantity>
      <split:account 
type="guid">2c60936ed64493bbac454d355225b052</split:account>
      <split:slots>
        <slot>
          <slot:key>sched-xaction</slot:key>
          <slot:value type="frame">
            <slot>
              <slot:key>credit-formula</slot:key>
              <slot:value type="string">25.32</slot:value>
            </slot>
            <slot>
              <slot:key>account</slot:key>
              <slot:value 
type="guid">b0853faaca8fad4e60d2a3f6b0b70261</slot:value>
            </slot>
            <slot>
              <slot:key>debit-formula</slot:key>
              <slot:value type="string"></slot:value>
            </slot>
          </slot:value>
        </slot>
      </split:slots>
    </trn:split>
  </trn:splits>
</gnc:transaction>

SECOND:
Then, I checked that the accounts exist for every split:
gnucash_db=# select distinct account_guid from splits except select guid 
from accounts;
 account_guid
--------------
(0 rows)

THIRD:
I checked that a commodity exists for every price.
gnucash_db=# select distinct commodity_guid from prices except select 
guid from commodities;
 commodity_guid
----------------
(0 rows)

FOURTH:
There is a currency_guid column in the transactions table.  However, 
there is no currency table.  What does this refer to?

I have not made use of the business functions, so I have no entries in 
other tables to check.

Mark


More information about the gnucash-devel mailing list