DB design document

Phillip Shelton shelton@usq.edu.au
Mon, 18 Dec 2000 11:53:22 +1000


(Taken from David M's schema.txt)

ACCOUNT
-------
account_guid                    char    32
parent_account_guid             char    32      -> account.account_guid
account_type                    integer         ->
account_types.acct_type_code
account_code                    char    20      a mnemonic for the user
account_name                    text            bank, lienholder, etc.
description                     text            long explanation of the
account
commodity_guid                  char    32      ->
commodities.commodity_guid


currency_code                   char    3       -> currency.currency_code
security_code
currency_scu                                    smallest convertible unit
security_scu                                    smallest convertible unit
balance                         rational
cleared_balance                 rational
reconciled_balance              rational
share_balance                   rational
share_cleared_balance           rational
share_reconciled_balance        rational
kvp_data                                        ???

Holds a record for each account.

The scu is used as the denominator in splits against this account. It is
enforced by the engine. Why do we not just use what is defined for the
commodity?

<my comment>
Dave P has answered this one.
</my comment>

Accounts can have subaccounts. The subaccounts are identified by the
parent_account_guid, which indicates the parent account.

<question>
What happens for the accounts that have no parent?

If an account has both children and splits, what would the SQL be if you
wanted to look at all the splits under that account whether in the account
directly or the child?
</question>

Phill