Re: Implementing "thick"/"fat" databases

From: David Johnston <polobo(at)yahoo(dot)com>
To: Darren Duncan <darren(at)darrenduncan(dot)net>
Cc: Karl Nack <karlnack(at)futurityinc(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Implementing "thick"/"fat" databases
Date: 2011-07-23 23:24:15
Message-ID: B113914E-0E3D-41B9-ACE7-78B0BDE512DE@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>
> I was assuming here that we were dealing with a double-entry accounting system where every line item in one account had a corresponding line item in another account of equal magnitude, and so all line items were in pairs, because you showed what looked like 1 pair, hence specifying the "50" once makes sense.
>
> So are you wanting the 1 function to take a set of line-item pairs, or are you wanting to say do +50 in one account and -25 in each of 2 different accounts, as a total of 3 line items? If the former, I would still just specify the "50" once and have a set of {from, to, amount} triples as an argument, which would be relation/rowset-typed. If the latter, then you would specify the "50" twice.

A little OT but all double-entry accounting requires is that the debits and credits of an entry - when totaled - equal zero (are equal); there is no requirement pertaining to each item having an equal but opposite counter-part. Nor are multiple accounts required; some ad-hoc entries simply "re-class" money within a single account so that different "controls" and/or amounts remain.

Ideally what you would want is a type called "accounting detail entry" which represents a credit/debit. For the function you can either make any "negative" amounts credits OR pass in two arrays - one for debits and one for credits. Either way you'd pass in an array of this "accounting detail entry" type along with information such as accounting date and journal number. To avoid using a type I would make a "create_entry" function that you'd use to create the detail items on a staging table, attached to a specific ID, and then create the final entry by calling the original function with user/date/journal/etc information and reference the detail records via the ID.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2011-07-23 23:51:02 Re: Implementing "thick"/"fat" databases
Previous Message Karl Nack 2011-07-23 23:08:21 Re: Implementing "thick"/"fat" databases