Вы находитесь на странице: 1из 11

2/6/2019 Database schema design for a double entry accounting system?

- Stack Overflow

Database schema design for a double Ask Question

entry accounting system?

Does anybody
know or have any
41 links to websites
describing details
of how to design a
database schema
for a double entry
45 accounting system
??.

I did find a bunch


of articles but non
were very
explanatory
enough. Would
appreciate it if
someone could
help me on this.

database

database-design

accounting

edited Apr 2 '11 at 21:10


Kenny Evitt
5,901 3 45 60

asked Mar 22 '10 at 17:24


soden
204 1 4 6

protected by
Community ♦
Sep 14 '15 at
23:45
This question is
protected to
prevent "thanks!",

https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 1/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

"me too!", or spam


answers by new
users. To answer
it, you must have
earned at least 10
reputation on this
site (the
association bonus
does not count).

@soden - what
specific part of
which specific
article do you
wish to have
help on? – DVK
Mar 22 '10 at
17:52

i do have a basic
understanding of
double entry
book keeping but
converting this
concept into a
database
schema ,,,, well i
guesse my
creative juices
arent flowing in
this one. –
soden Mar 22
'10 at 17:56

3 Answers

Here's one link


that you may find
38 helpful:

http://homepages.t
cp.co.uk/~m-
wigley/gc_wp_ded
.html

Updated:
Alternative links
(as original one
seems to be
broken):

https://mediu
m.com/@Rob
ertKhou/doubl
e-entry-
accounting-in-
https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 2/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

a-relational-
database-
2b7838a5d7f
8 (Complete
article with
images)
https://vikram
pareek.wordp
ress.com/201
2/09/19/185/
http://acc4ara
b.com/acc/sh
owthread.php
?t=4227

ited Jan 15 '17 at 10:13


J4R
35 1 3

swered Mar 22 '10 at 17:31


Leslie
2,369 5 29 42

i did read this


one. but didnt
actually know
how to use it.
Some sql
examples would
be icing on the
cake :). thnx by
the way –
soden Mar 22
'10 at 17:40

1 do you have an
accounting
background? I
spent 10+ years
in accounting
and would
hesitate to
create an
accounting
package from
scratch...the
article linked
above is a very
good example
of table setup
and accounting
processes.
What kind of
SQL examples
would you like?
– Leslie Mar 22
'10 at 18:56

cuppadev.co.uk/

https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 3/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

dev/double-
entry-
accounting-in-
rails this link
does explain the
same stuff. but
im now sure
how i am
supposed to
start building
the database
schema. i am
well versed in
RDBMS and
some basic
accounting
which i learnt
thorugh self
study in the past
few weeks. im
just confused .
id be nice if you
could help me
on this. –
soden Mar 25
'10 at 5:48

The link is
informative:
however, at the
level that things
are explained, if
you are just
about
understanding
what is written
then you are in
no position to
start writing
your own
program. –
khany Feb 16
'12 at 17:45

4 Link is dead; but


here's wayback
machine's
snapshot:
Double Entry
Accounting in a
Relational
Database –
Majid Fouladpour
Jan 19 '14 at
16:13

https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 4/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

Create the
following tables
38 account
transaction
line_item
contact (can
be a customer
a supplier, or
an employee).

To keep things
simple, we will
leave out the
account_type
table, contact_type
table, etc.

Identify the
relationships
between the
tables and set
them up

a contact can
have many
transactions,
but each
transaction
can only have
one contact
(one-to-many
relationship)
an account
can have
many
transactions,
and one
transaction
can affect
many
accounts;
line_item is
the join table
between
transaction
table and
account table
(a many-to-
many
relationship)
a transaction
can have
https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 5/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

many line
items, but
each line item
must relate to
one
transaction.

We have the
following schema
(a one-to-many
relationship):

CONTACT ———< TRANSA

Add appropriate
fields to each
table

Contact
contactID
name
addr1
addr2
city
state
zip
phone
fax
email
Transaction
transactio
nID
date
memo1
contactID
ref
Line_item
line_itemI
D
transactio
nID
accountID
amount
memo2
Account
accountID
https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 6/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

account_
name
account_t
ype

Create as many
new transactions
as needed

For example to
add a new
transaction in the
database, add a
new record in the
transaction table
and fill in the fields,
select a contact
name, enter a
date, etc. Then
add new child
records to the
parent transaction
record for each
account affected.
Each transaction
record must have
at least two child
records (in a
double-entry
bookkeeping
system). If I
purchased some
cheese for $20
cash, add a child
record to the
transaction record
in the child record,
select the Cash
account and record
−20.00 (negative)
in the amount field.
Add a new child
record, select the
Groceries account
and record 20.00
(positive) in the
amount field. The
sum of the child
records should be
zero (i.e., 20.00 −
20.00 = 0.00).

Create reports in
the database
based on the data
https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 7/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

stored in the
above tables

The query to give


me all records in
the database
organized so that
transaction line
item child records
are grouped by
account, sorted by
date then by
transaction ID.
Create a
calculation field
that gives the
running total of the
amount field in the
transaction
line_items records
and any other
calculation fields
you find necessary.
If you prefer to
show amounts in
debit/credit format,
create two
calculation fields in
the database query
have one field
called debit, and
another called
credit. In the debit
calculation field,
enter the formula
"if the amount in
the amount field
from the line_item
table is positive,
show the amount,
otherwise null". In
the credit
calculation field,
enter the formula
"if the amount in
the amount field
from the line-Item
table is negative,
show the amount,
otherwise null".

Based on this
rather simple
database design,
you can
https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 8/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

continuously add
more fields, tables
and reports to add
more complexity to
your database to
track yours or your
business finances.

ited Aug 15 '18 at 4:59


Olim Saidov
2,102 1 13 27

swered Mar 23 '13 at 3:55


bkire
381 3 2

I figured I might as
well take a stab at
9 it. Comments are
appreciated – I'll
refine the design
based on feedback
from anyone. I'm
going to use SQL
Server (2005) T-
SQL syntax for
now, but if anyone
is interested in
other languages,
let me know and I'll
add additional
examples.

In a double-entry
bookkeeping
system, the basic
elements are
accounts and
transactions. The
basic 'theory' is the
accounting
equation: Equity =
Assets - Liabilities.

Combining the
items in the
accounting
equation and two
types of nominal
accounts, Income
and Expenses, the
basic organization
https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 9/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

of the accounts is
simply a forest of
nested accounts,
the root of the
(minimum) five
trees being one of:
Assets, Liabilities,
Equity, Income,
and Expenses.

[I'm researching
good SQL designs
for hierarchies
generally ... I'll
update this with
specifics later.]

One interesting
hierarchy design is
documented in the
SQL Team article
More Trees &
Hierarchies in
SQL.

Every transaction
consists of
balanced debit and
credit amounts.
For every
transaction, the
total of the debit
amounts and the
total of the credit
amounts must be
exactly equal.
Every debit and
credit amount is
tied to one
account.

[More to follow ...]

ited Sep 13 '12 at 8:31

ommunity wiki
revs, 2 users 96%
enny Evitt

Note that my
answer is
'community wiki'
– please feel
free to edit it
https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 10/11
2/6/2019 Database schema design for a double entry accounting system? - Stack Overflow

yourself. –
Kenny Evitt Apr
2 '11 at 20:56

https://stackoverflow.com/questions/2494343/database-schema-design-for-a-double-entry-accounting-system 11/11

Вам также может понравиться