Subject | Store Sum Value in Table |
---|---|
Author | Ivan Setya Darmawan |
Post date | 2006-04-01T02:49:19Z |
I need to create a tree structure for my accounting application
like below:
Account Type Balance
----------------- ------- --------
Asset Header 1000
Current Asset Header 500
Cash Detail 250
Inventory Detail 250
Fixed Asset Header 500
Furniture Detail 250
Building Detail 250
Liability Header 500
Current Liability Header 500
Account Payable Detail 250
Tax Payable Detail 250
Currently, I have succeded to create database structure and show them
in VirtualTreeView. I use Delphi. I use latest stable FB version.
My question is related to the table structure. All account_id,
account_parrent_id, and balance_value are stored in the same table.
The table not just store the Details value but also the Headers value
(sum of Details). Some SP's has been created to fill the Headers value
automatically. These SP's executed when the Details Account inserted,
deleted, or updated. These SP's also insert and update Header
accounts and its values when needed.
I know this is not comply with normalization technique (where you have
to avoid to store the sum value). But, my consideration are:
(1) I don't have to code the Headers value (sum of Details) in the
client application.
(2) There are no calculation in the client application.
(3) VirtualTreeView will show the data tree very fast because it had
just fetch the plain data.
(4) There are no calculation in report designer because it had just
fetch the plain data.
Is it still good practise to store Headers value (sum of Details) in
the table regarding my consideration? My database has not yet tested
with large data and I use double precision type to store the currency
value.
Go.. go.. Firebird. It's been nice 6 month experience using Firebird.
You got new kid here :)
TIA, sorry for my english.
#ivan_darmawan
like below:
Account Type Balance
----------------- ------- --------
Asset Header 1000
Current Asset Header 500
Cash Detail 250
Inventory Detail 250
Fixed Asset Header 500
Furniture Detail 250
Building Detail 250
Liability Header 500
Current Liability Header 500
Account Payable Detail 250
Tax Payable Detail 250
Currently, I have succeded to create database structure and show them
in VirtualTreeView. I use Delphi. I use latest stable FB version.
My question is related to the table structure. All account_id,
account_parrent_id, and balance_value are stored in the same table.
The table not just store the Details value but also the Headers value
(sum of Details). Some SP's has been created to fill the Headers value
automatically. These SP's executed when the Details Account inserted,
deleted, or updated. These SP's also insert and update Header
accounts and its values when needed.
I know this is not comply with normalization technique (where you have
to avoid to store the sum value). But, my consideration are:
(1) I don't have to code the Headers value (sum of Details) in the
client application.
(2) There are no calculation in the client application.
(3) VirtualTreeView will show the data tree very fast because it had
just fetch the plain data.
(4) There are no calculation in report designer because it had just
fetch the plain data.
Is it still good practise to store Headers value (sum of Details) in
the table regarding my consideration? My database has not yet tested
with large data and I use double precision type to store the currency
value.
Go.. go.. Firebird. It's been nice 6 month experience using Firebird.
You got new kid here :)
TIA, sorry for my english.
#ivan_darmawan