GnuCash and Postgres

Josh Sled jsled at asynchronous.org
Wed Aug 24 18:17:41 EDT 2005


On Wed, 2005-08-24 at 14:50 -0700, ted creedon wrote:
>  How would you define "all transactions must be balanced" in SQL?
> 
> > You don't. I would suggest using Visio Enterprise Architect for the Data
> Modeling though.

Sure you can; the following model does not admit unbalanced
transactions:

create table accounts
  ( account_id int identity not null,
    name #...,
  )

create table amounts
  ( amount_id int identity not null,
    value float not null,
    credit_account_id int not null foreign key (accounts.account_id),
    debit_account_id int not null foreign key (accounts.account_id)
  )

create table transactions
  ( txn_id int identity not null,
    description varchar(255),
    # dates, &c.
  )

create table transaction_values
  ( transaction_id int not null foreign key (transactions.txn_id)
    value_idx int not null, -- 0,1,2,3,...
    amount_id int not null foreign key (amounts.amount_id)
    primary key (transaction_id,split_idx)
  )

But I agree with Derek -- it's besides the point.  The whole concept of
"well I can just insert randomly into some other app's database!" breaks
down rather quickly.

And re: the quoting.

...jsled

-- 
http://asynchronous.org/ - `a=jsled; b=asynchronous.org; echo ${a}@${b}`


More information about the gnucash-user mailing list