dbTalk Databases Forums  

Calculated value dilemma

comp.databases.theory comp.databases.theory


Discuss Calculated value dilemma in the comp.databases.theory forum.



Reply
 
Thread Tools Display Modes
  #41  
Old   
Tim X
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 04:06 AM






Rainboy <mark.rainbow (AT) gmail (DOT) com> writes:

Quote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

I think you may be a little off the mark with your interpretation of
3NF. Its not about not storing calculated values. Although a bit
simplistic, think of it as not having the same data stored in multiple
places because then you can get data inconsistencies when one copy is
updated and the other is not - how do you determine which is correct?

Also, don't worry too much about efficiency initially. What your
describing is normal expected application of the technology. You also
don't seem to be dealing with that many records given common data set
sizes and the processing power of hardware these days. Optimizing too
early is often a fatal mistake. Wait and see (ideally in a testing stage
rather than a production stage - you will be surprised how much
performance can be affected by the right use of indexes. If performance
becomes an issue and you cannot resolve it with available database
features (partitioning, indexing, summary tables, views etc) then you
can consider using summary tables and data archiving etc.

Quote:
However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...
Think about it from a different perspective. The problem isn't that the
balances get all messed up. The problem is allowing historical data to
be modified. If you cannot change the balance or date of a record and
you cannot insert a record with a retrospective date, then your
historical data doesn't change and hence any calculations based on that
data doesn't change. Note that most accountants and auditors would not
be very impressed with any system that allowed either updates of past
records or insertion of records retrospectively.
Quote:
IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Personally, I'd avoid storing the balance unless the calculation of that
balance is too resource hungry. As long as you can't change data
retrospectively and can't insert records retrospectively, just calculate
the balance when you need it.

What I would possibly do is -

1. Use a timestamp on the records that is automatically set when you
insert the record. i.e. not set by the user.

2. If performance becomes an issue, consider having either some form of
partitioning or end of month process. Track when the end of month
process has been run and use that to generate a historical summary
table. If/when you need a detailed report that covers more than the
current period, use the data in the historical summary table.

3. Take advantage of 300 years of modern accounting practices and design
your system as a double entry accounting system. This provides
additional checks and balances and you tend to get lots of other
benefits, such as simplified auditing processes. Include the ability to
enter bank statements or deposit receipts. This can be used to ensure
everything balances. Don't allow a month to be closed off until
everythinig balances.

4. Ensure you have some type of journaling function that will enable
adjustments. Data will be entered incorrectly - that is the one thing
you can guarantee - for example, simple transposing of numbers during
data entry etc. You need to be able to 'fix' such things and you need to
be able to do it in an acceptable way from and accounting and auditing
perspective. Rule of thumb, you should be able to reproduce *all* the
data entry processes that have occured easily and pretty much
transparently.

5. If your database supports constraints (foreign keys, check
constraints, not null, primary key constraints, etc then use them. In
the short term, it may feel like a lot of extra work, but once you start
coding the application logic, things become a lot easier. Much better to
prevent bad data from getting in than trying to fix it once it does.

6. Make sure you thoroughly know and understand how this information is
recorded and managed now. I'm assuming it is a manual system. Being
really familiar with current practice will provide valuable information
in both the design of your underlying data model and the overall
implementation. Don't try to just replicate the process using technology
- your solution wil almost certainly require those who manage the
process to refine their process, but make sure you understand their
current process before trying to design them a new one.

Finally, make sure there isn't an affordable or open source solution
that would suffice. Building such an application is a fun project and if
its for an organisation you feel warrants such support, its generally a
good thing. However, all applications need maintenance and support. If
your not prepared or unable to provide this maintenance and support,
they need to get it from somewhere else and it can come at a cost -
particularly for one off custom apps. Given you have never designed and
implemented a database and application before, you are almost certainly
going to get things wrong. I've been working in the industry for over 20
years and I still get things wrong - the only difference is that I get
it wrong less often and when I do it tends to be less critical.

good luck

Tim

--
tcross (at) rapttech dot com dot au


Reply With Quote
  #42  
Old   
Tim X
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 04:06 AM






Rainboy <mark.rainbow (AT) gmail (DOT) com> writes:

Quote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

I think you may be a little off the mark with your interpretation of
3NF. Its not about not storing calculated values. Although a bit
simplistic, think of it as not having the same data stored in multiple
places because then you can get data inconsistencies when one copy is
updated and the other is not - how do you determine which is correct?

Also, don't worry too much about efficiency initially. What your
describing is normal expected application of the technology. You also
don't seem to be dealing with that many records given common data set
sizes and the processing power of hardware these days. Optimizing too
early is often a fatal mistake. Wait and see (ideally in a testing stage
rather than a production stage - you will be surprised how much
performance can be affected by the right use of indexes. If performance
becomes an issue and you cannot resolve it with available database
features (partitioning, indexing, summary tables, views etc) then you
can consider using summary tables and data archiving etc.

Quote:
However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...
Think about it from a different perspective. The problem isn't that the
balances get all messed up. The problem is allowing historical data to
be modified. If you cannot change the balance or date of a record and
you cannot insert a record with a retrospective date, then your
historical data doesn't change and hence any calculations based on that
data doesn't change. Note that most accountants and auditors would not
be very impressed with any system that allowed either updates of past
records or insertion of records retrospectively.
Quote:
IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Personally, I'd avoid storing the balance unless the calculation of that
balance is too resource hungry. As long as you can't change data
retrospectively and can't insert records retrospectively, just calculate
the balance when you need it.

What I would possibly do is -

1. Use a timestamp on the records that is automatically set when you
insert the record. i.e. not set by the user.

2. If performance becomes an issue, consider having either some form of
partitioning or end of month process. Track when the end of month
process has been run and use that to generate a historical summary
table. If/when you need a detailed report that covers more than the
current period, use the data in the historical summary table.

3. Take advantage of 300 years of modern accounting practices and design
your system as a double entry accounting system. This provides
additional checks and balances and you tend to get lots of other
benefits, such as simplified auditing processes. Include the ability to
enter bank statements or deposit receipts. This can be used to ensure
everything balances. Don't allow a month to be closed off until
everythinig balances.

4. Ensure you have some type of journaling function that will enable
adjustments. Data will be entered incorrectly - that is the one thing
you can guarantee - for example, simple transposing of numbers during
data entry etc. You need to be able to 'fix' such things and you need to
be able to do it in an acceptable way from and accounting and auditing
perspective. Rule of thumb, you should be able to reproduce *all* the
data entry processes that have occured easily and pretty much
transparently.

5. If your database supports constraints (foreign keys, check
constraints, not null, primary key constraints, etc then use them. In
the short term, it may feel like a lot of extra work, but once you start
coding the application logic, things become a lot easier. Much better to
prevent bad data from getting in than trying to fix it once it does.

6. Make sure you thoroughly know and understand how this information is
recorded and managed now. I'm assuming it is a manual system. Being
really familiar with current practice will provide valuable information
in both the design of your underlying data model and the overall
implementation. Don't try to just replicate the process using technology
- your solution wil almost certainly require those who manage the
process to refine their process, but make sure you understand their
current process before trying to design them a new one.

Finally, make sure there isn't an affordable or open source solution
that would suffice. Building such an application is a fun project and if
its for an organisation you feel warrants such support, its generally a
good thing. However, all applications need maintenance and support. If
your not prepared or unable to provide this maintenance and support,
they need to get it from somewhere else and it can come at a cost -
particularly for one off custom apps. Given you have never designed and
implemented a database and application before, you are almost certainly
going to get things wrong. I've been working in the industry for over 20
years and I still get things wrong - the only difference is that I get
it wrong less often and when I do it tends to be less critical.

good luck

Tim

--
tcross (at) rapttech dot com dot au


Reply With Quote
  #43  
Old   
Tim X
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 04:06 AM



Rainboy <mark.rainbow (AT) gmail (DOT) com> writes:

Quote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

I think you may be a little off the mark with your interpretation of
3NF. Its not about not storing calculated values. Although a bit
simplistic, think of it as not having the same data stored in multiple
places because then you can get data inconsistencies when one copy is
updated and the other is not - how do you determine which is correct?

Also, don't worry too much about efficiency initially. What your
describing is normal expected application of the technology. You also
don't seem to be dealing with that many records given common data set
sizes and the processing power of hardware these days. Optimizing too
early is often a fatal mistake. Wait and see (ideally in a testing stage
rather than a production stage - you will be surprised how much
performance can be affected by the right use of indexes. If performance
becomes an issue and you cannot resolve it with available database
features (partitioning, indexing, summary tables, views etc) then you
can consider using summary tables and data archiving etc.

Quote:
However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...
Think about it from a different perspective. The problem isn't that the
balances get all messed up. The problem is allowing historical data to
be modified. If you cannot change the balance or date of a record and
you cannot insert a record with a retrospective date, then your
historical data doesn't change and hence any calculations based on that
data doesn't change. Note that most accountants and auditors would not
be very impressed with any system that allowed either updates of past
records or insertion of records retrospectively.
Quote:
IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Personally, I'd avoid storing the balance unless the calculation of that
balance is too resource hungry. As long as you can't change data
retrospectively and can't insert records retrospectively, just calculate
the balance when you need it.

What I would possibly do is -

1. Use a timestamp on the records that is automatically set when you
insert the record. i.e. not set by the user.

2. If performance becomes an issue, consider having either some form of
partitioning or end of month process. Track when the end of month
process has been run and use that to generate a historical summary
table. If/when you need a detailed report that covers more than the
current period, use the data in the historical summary table.

3. Take advantage of 300 years of modern accounting practices and design
your system as a double entry accounting system. This provides
additional checks and balances and you tend to get lots of other
benefits, such as simplified auditing processes. Include the ability to
enter bank statements or deposit receipts. This can be used to ensure
everything balances. Don't allow a month to be closed off until
everythinig balances.

4. Ensure you have some type of journaling function that will enable
adjustments. Data will be entered incorrectly - that is the one thing
you can guarantee - for example, simple transposing of numbers during
data entry etc. You need to be able to 'fix' such things and you need to
be able to do it in an acceptable way from and accounting and auditing
perspective. Rule of thumb, you should be able to reproduce *all* the
data entry processes that have occured easily and pretty much
transparently.

5. If your database supports constraints (foreign keys, check
constraints, not null, primary key constraints, etc then use them. In
the short term, it may feel like a lot of extra work, but once you start
coding the application logic, things become a lot easier. Much better to
prevent bad data from getting in than trying to fix it once it does.

6. Make sure you thoroughly know and understand how this information is
recorded and managed now. I'm assuming it is a manual system. Being
really familiar with current practice will provide valuable information
in both the design of your underlying data model and the overall
implementation. Don't try to just replicate the process using technology
- your solution wil almost certainly require those who manage the
process to refine their process, but make sure you understand their
current process before trying to design them a new one.

Finally, make sure there isn't an affordable or open source solution
that would suffice. Building such an application is a fun project and if
its for an organisation you feel warrants such support, its generally a
good thing. However, all applications need maintenance and support. If
your not prepared or unable to provide this maintenance and support,
they need to get it from somewhere else and it can come at a cost -
particularly for one off custom apps. Given you have never designed and
implemented a database and application before, you are almost certainly
going to get things wrong. I've been working in the industry for over 20
years and I still get things wrong - the only difference is that I get
it wrong less often and when I do it tends to be less critical.

good luck

Tim

--
tcross (at) rapttech dot com dot au


Reply With Quote
  #44  
Old   
Tim X
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 04:06 AM



Rainboy <mark.rainbow (AT) gmail (DOT) com> writes:

Quote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

I think you may be a little off the mark with your interpretation of
3NF. Its not about not storing calculated values. Although a bit
simplistic, think of it as not having the same data stored in multiple
places because then you can get data inconsistencies when one copy is
updated and the other is not - how do you determine which is correct?

Also, don't worry too much about efficiency initially. What your
describing is normal expected application of the technology. You also
don't seem to be dealing with that many records given common data set
sizes and the processing power of hardware these days. Optimizing too
early is often a fatal mistake. Wait and see (ideally in a testing stage
rather than a production stage - you will be surprised how much
performance can be affected by the right use of indexes. If performance
becomes an issue and you cannot resolve it with available database
features (partitioning, indexing, summary tables, views etc) then you
can consider using summary tables and data archiving etc.

Quote:
However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...
Think about it from a different perspective. The problem isn't that the
balances get all messed up. The problem is allowing historical data to
be modified. If you cannot change the balance or date of a record and
you cannot insert a record with a retrospective date, then your
historical data doesn't change and hence any calculations based on that
data doesn't change. Note that most accountants and auditors would not
be very impressed with any system that allowed either updates of past
records or insertion of records retrospectively.
Quote:
IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Personally, I'd avoid storing the balance unless the calculation of that
balance is too resource hungry. As long as you can't change data
retrospectively and can't insert records retrospectively, just calculate
the balance when you need it.

What I would possibly do is -

1. Use a timestamp on the records that is automatically set when you
insert the record. i.e. not set by the user.

2. If performance becomes an issue, consider having either some form of
partitioning or end of month process. Track when the end of month
process has been run and use that to generate a historical summary
table. If/when you need a detailed report that covers more than the
current period, use the data in the historical summary table.

3. Take advantage of 300 years of modern accounting practices and design
your system as a double entry accounting system. This provides
additional checks and balances and you tend to get lots of other
benefits, such as simplified auditing processes. Include the ability to
enter bank statements or deposit receipts. This can be used to ensure
everything balances. Don't allow a month to be closed off until
everythinig balances.

4. Ensure you have some type of journaling function that will enable
adjustments. Data will be entered incorrectly - that is the one thing
you can guarantee - for example, simple transposing of numbers during
data entry etc. You need to be able to 'fix' such things and you need to
be able to do it in an acceptable way from and accounting and auditing
perspective. Rule of thumb, you should be able to reproduce *all* the
data entry processes that have occured easily and pretty much
transparently.

5. If your database supports constraints (foreign keys, check
constraints, not null, primary key constraints, etc then use them. In
the short term, it may feel like a lot of extra work, but once you start
coding the application logic, things become a lot easier. Much better to
prevent bad data from getting in than trying to fix it once it does.

6. Make sure you thoroughly know and understand how this information is
recorded and managed now. I'm assuming it is a manual system. Being
really familiar with current practice will provide valuable information
in both the design of your underlying data model and the overall
implementation. Don't try to just replicate the process using technology
- your solution wil almost certainly require those who manage the
process to refine their process, but make sure you understand their
current process before trying to design them a new one.

Finally, make sure there isn't an affordable or open source solution
that would suffice. Building such an application is a fun project and if
its for an organisation you feel warrants such support, its generally a
good thing. However, all applications need maintenance and support. If
your not prepared or unable to provide this maintenance and support,
they need to get it from somewhere else and it can come at a cost -
particularly for one off custom apps. Given you have never designed and
implemented a database and application before, you are almost certainly
going to get things wrong. I've been working in the industry for over 20
years and I still get things wrong - the only difference is that I get
it wrong less often and when I do it tends to be less critical.

good luck

Tim

--
tcross (at) rapttech dot com dot au


Reply With Quote
  #45  
Old   
Tim X
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 04:06 AM



Rainboy <mark.rainbow (AT) gmail (DOT) com> writes:

Quote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

I think you may be a little off the mark with your interpretation of
3NF. Its not about not storing calculated values. Although a bit
simplistic, think of it as not having the same data stored in multiple
places because then you can get data inconsistencies when one copy is
updated and the other is not - how do you determine which is correct?

Also, don't worry too much about efficiency initially. What your
describing is normal expected application of the technology. You also
don't seem to be dealing with that many records given common data set
sizes and the processing power of hardware these days. Optimizing too
early is often a fatal mistake. Wait and see (ideally in a testing stage
rather than a production stage - you will be surprised how much
performance can be affected by the right use of indexes. If performance
becomes an issue and you cannot resolve it with available database
features (partitioning, indexing, summary tables, views etc) then you
can consider using summary tables and data archiving etc.

Quote:
However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...
Think about it from a different perspective. The problem isn't that the
balances get all messed up. The problem is allowing historical data to
be modified. If you cannot change the balance or date of a record and
you cannot insert a record with a retrospective date, then your
historical data doesn't change and hence any calculations based on that
data doesn't change. Note that most accountants and auditors would not
be very impressed with any system that allowed either updates of past
records or insertion of records retrospectively.
Quote:
IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Personally, I'd avoid storing the balance unless the calculation of that
balance is too resource hungry. As long as you can't change data
retrospectively and can't insert records retrospectively, just calculate
the balance when you need it.

What I would possibly do is -

1. Use a timestamp on the records that is automatically set when you
insert the record. i.e. not set by the user.

2. If performance becomes an issue, consider having either some form of
partitioning or end of month process. Track when the end of month
process has been run and use that to generate a historical summary
table. If/when you need a detailed report that covers more than the
current period, use the data in the historical summary table.

3. Take advantage of 300 years of modern accounting practices and design
your system as a double entry accounting system. This provides
additional checks and balances and you tend to get lots of other
benefits, such as simplified auditing processes. Include the ability to
enter bank statements or deposit receipts. This can be used to ensure
everything balances. Don't allow a month to be closed off until
everythinig balances.

4. Ensure you have some type of journaling function that will enable
adjustments. Data will be entered incorrectly - that is the one thing
you can guarantee - for example, simple transposing of numbers during
data entry etc. You need to be able to 'fix' such things and you need to
be able to do it in an acceptable way from and accounting and auditing
perspective. Rule of thumb, you should be able to reproduce *all* the
data entry processes that have occured easily and pretty much
transparently.

5. If your database supports constraints (foreign keys, check
constraints, not null, primary key constraints, etc then use them. In
the short term, it may feel like a lot of extra work, but once you start
coding the application logic, things become a lot easier. Much better to
prevent bad data from getting in than trying to fix it once it does.

6. Make sure you thoroughly know and understand how this information is
recorded and managed now. I'm assuming it is a manual system. Being
really familiar with current practice will provide valuable information
in both the design of your underlying data model and the overall
implementation. Don't try to just replicate the process using technology
- your solution wil almost certainly require those who manage the
process to refine their process, but make sure you understand their
current process before trying to design them a new one.

Finally, make sure there isn't an affordable or open source solution
that would suffice. Building such an application is a fun project and if
its for an organisation you feel warrants such support, its generally a
good thing. However, all applications need maintenance and support. If
your not prepared or unable to provide this maintenance and support,
they need to get it from somewhere else and it can come at a cost -
particularly for one off custom apps. Given you have never designed and
implemented a database and application before, you are almost certainly
going to get things wrong. I've been working in the industry for over 20
years and I still get things wrong - the only difference is that I get
it wrong less often and when I do it tends to be less critical.

good luck

Tim

--
tcross (at) rapttech dot com dot au


Reply With Quote
  #46  
Old   
Tim X
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 04:06 AM



Rainboy <mark.rainbow (AT) gmail (DOT) com> writes:

Quote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

I think you may be a little off the mark with your interpretation of
3NF. Its not about not storing calculated values. Although a bit
simplistic, think of it as not having the same data stored in multiple
places because then you can get data inconsistencies when one copy is
updated and the other is not - how do you determine which is correct?

Also, don't worry too much about efficiency initially. What your
describing is normal expected application of the technology. You also
don't seem to be dealing with that many records given common data set
sizes and the processing power of hardware these days. Optimizing too
early is often a fatal mistake. Wait and see (ideally in a testing stage
rather than a production stage - you will be surprised how much
performance can be affected by the right use of indexes. If performance
becomes an issue and you cannot resolve it with available database
features (partitioning, indexing, summary tables, views etc) then you
can consider using summary tables and data archiving etc.

Quote:
However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...
Think about it from a different perspective. The problem isn't that the
balances get all messed up. The problem is allowing historical data to
be modified. If you cannot change the balance or date of a record and
you cannot insert a record with a retrospective date, then your
historical data doesn't change and hence any calculations based on that
data doesn't change. Note that most accountants and auditors would not
be very impressed with any system that allowed either updates of past
records or insertion of records retrospectively.
Quote:
IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Personally, I'd avoid storing the balance unless the calculation of that
balance is too resource hungry. As long as you can't change data
retrospectively and can't insert records retrospectively, just calculate
the balance when you need it.

What I would possibly do is -

1. Use a timestamp on the records that is automatically set when you
insert the record. i.e. not set by the user.

2. If performance becomes an issue, consider having either some form of
partitioning or end of month process. Track when the end of month
process has been run and use that to generate a historical summary
table. If/when you need a detailed report that covers more than the
current period, use the data in the historical summary table.

3. Take advantage of 300 years of modern accounting practices and design
your system as a double entry accounting system. This provides
additional checks and balances and you tend to get lots of other
benefits, such as simplified auditing processes. Include the ability to
enter bank statements or deposit receipts. This can be used to ensure
everything balances. Don't allow a month to be closed off until
everythinig balances.

4. Ensure you have some type of journaling function that will enable
adjustments. Data will be entered incorrectly - that is the one thing
you can guarantee - for example, simple transposing of numbers during
data entry etc. You need to be able to 'fix' such things and you need to
be able to do it in an acceptable way from and accounting and auditing
perspective. Rule of thumb, you should be able to reproduce *all* the
data entry processes that have occured easily and pretty much
transparently.

5. If your database supports constraints (foreign keys, check
constraints, not null, primary key constraints, etc then use them. In
the short term, it may feel like a lot of extra work, but once you start
coding the application logic, things become a lot easier. Much better to
prevent bad data from getting in than trying to fix it once it does.

6. Make sure you thoroughly know and understand how this information is
recorded and managed now. I'm assuming it is a manual system. Being
really familiar with current practice will provide valuable information
in both the design of your underlying data model and the overall
implementation. Don't try to just replicate the process using technology
- your solution wil almost certainly require those who manage the
process to refine their process, but make sure you understand their
current process before trying to design them a new one.

Finally, make sure there isn't an affordable or open source solution
that would suffice. Building such an application is a fun project and if
its for an organisation you feel warrants such support, its generally a
good thing. However, all applications need maintenance and support. If
your not prepared or unable to provide this maintenance and support,
they need to get it from somewhere else and it can come at a cost -
particularly for one off custom apps. Given you have never designed and
implemented a database and application before, you are almost certainly
going to get things wrong. I've been working in the industry for over 20
years and I still get things wrong - the only difference is that I get
it wrong less often and when I do it tends to be less critical.

good luck

Tim

--
tcross (at) rapttech dot com dot au


Reply With Quote
  #47  
Old   
JOG
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 06:33 AM



On Jul 16, 3:00 pm, Rainboy <mark.rain... (AT) gmail (DOT) com> wrote:
Quote:
On Jul 16, 1:13 pm, Bob Badour <bbad... (AT) pei (DOT) sympatico.ca> wrote:



Rainboy wrote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

Where did you learn that was part of a normalization rule? It's just
plain wrong.

However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...

Historical data should accurately reflect the history. What if a
calculation changes? What if a calculation depends on the instantaneous
value of some attribute where no history is stored? As a hypothetical
situation, suppose families with 5 or more kids get a special discount.
When baby #5 is born, the family doesn't suddenly get a discount on all
their past transactions.

IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Exactly which normal form do you suppose it violates?

Any suggestions would be greatly appreciated!

Mark

PS I've never designed a database before, so please let me know if
I'm completely barking up the wrong tree!

I think you have been misinformed. Where are you getting your information?- Hide quoted text -

- Show quoted text -

Hmmmm...

Well, I had assumed that the table would be violating 3NF because the
calculated value of the balance would be dependent on the transaction
amount, which is not the primary key.
3NF is deprecated really. You should start at BCNF when normalizing.
Regards, J.

Quote:
Ah, I think I'm starting to understand... is historical data treated
differently because as soon as an entry is 'in the past', the balance
(at that time) no longer depends on the transaction amount, and it
does only depend on the primary key of transaction ID. So I just have
a balance column, and whenever I want someone's current balance, I
just query this historical table for the most recent entry? And I
won't be breaking any rules? Smooth.

Although (assuming I've got this right) something does intuitively
bother me about this... can't quite put my finger on it! I feel a bit
wary that the database's accuracy will depend on someone always
entering in the correct balance to square with the latest transaction
amount... what if they don't? I know it can be automated, but I don't
feel that comfy knowing that the database structure doesn't take care
of it, and it'll have to be some extra logic. Does this make sense?

Mark

PS Thanks for your reply. I hope you don't mind bearing with me
while I get my head around these new concepts!


Reply With Quote
  #48  
Old   
JOG
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 06:33 AM



On Jul 16, 3:00 pm, Rainboy <mark.rain... (AT) gmail (DOT) com> wrote:
Quote:
On Jul 16, 1:13 pm, Bob Badour <bbad... (AT) pei (DOT) sympatico.ca> wrote:



Rainboy wrote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

Where did you learn that was part of a normalization rule? It's just
plain wrong.

However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...

Historical data should accurately reflect the history. What if a
calculation changes? What if a calculation depends on the instantaneous
value of some attribute where no history is stored? As a hypothetical
situation, suppose families with 5 or more kids get a special discount.
When baby #5 is born, the family doesn't suddenly get a discount on all
their past transactions.

IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Exactly which normal form do you suppose it violates?

Any suggestions would be greatly appreciated!

Mark

PS I've never designed a database before, so please let me know if
I'm completely barking up the wrong tree!

I think you have been misinformed. Where are you getting your information?- Hide quoted text -

- Show quoted text -

Hmmmm...

Well, I had assumed that the table would be violating 3NF because the
calculated value of the balance would be dependent on the transaction
amount, which is not the primary key.
3NF is deprecated really. You should start at BCNF when normalizing.
Regards, J.

Quote:
Ah, I think I'm starting to understand... is historical data treated
differently because as soon as an entry is 'in the past', the balance
(at that time) no longer depends on the transaction amount, and it
does only depend on the primary key of transaction ID. So I just have
a balance column, and whenever I want someone's current balance, I
just query this historical table for the most recent entry? And I
won't be breaking any rules? Smooth.

Although (assuming I've got this right) something does intuitively
bother me about this... can't quite put my finger on it! I feel a bit
wary that the database's accuracy will depend on someone always
entering in the correct balance to square with the latest transaction
amount... what if they don't? I know it can be automated, but I don't
feel that comfy knowing that the database structure doesn't take care
of it, and it'll have to be some extra logic. Does this make sense?

Mark

PS Thanks for your reply. I hope you don't mind bearing with me
while I get my head around these new concepts!


Reply With Quote
  #49  
Old   
JOG
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 06:33 AM



On Jul 16, 3:00 pm, Rainboy <mark.rain... (AT) gmail (DOT) com> wrote:
Quote:
On Jul 16, 1:13 pm, Bob Badour <bbad... (AT) pei (DOT) sympatico.ca> wrote:



Rainboy wrote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

Where did you learn that was part of a normalization rule? It's just
plain wrong.

However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...

Historical data should accurately reflect the history. What if a
calculation changes? What if a calculation depends on the instantaneous
value of some attribute where no history is stored? As a hypothetical
situation, suppose families with 5 or more kids get a special discount.
When baby #5 is born, the family doesn't suddenly get a discount on all
their past transactions.

IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Exactly which normal form do you suppose it violates?

Any suggestions would be greatly appreciated!

Mark

PS I've never designed a database before, so please let me know if
I'm completely barking up the wrong tree!

I think you have been misinformed. Where are you getting your information?- Hide quoted text -

- Show quoted text -

Hmmmm...

Well, I had assumed that the table would be violating 3NF because the
calculated value of the balance would be dependent on the transaction
amount, which is not the primary key.
3NF is deprecated really. You should start at BCNF when normalizing.
Regards, J.

Quote:
Ah, I think I'm starting to understand... is historical data treated
differently because as soon as an entry is 'in the past', the balance
(at that time) no longer depends on the transaction amount, and it
does only depend on the primary key of transaction ID. So I just have
a balance column, and whenever I want someone's current balance, I
just query this historical table for the most recent entry? And I
won't be breaking any rules? Smooth.

Although (assuming I've got this right) something does intuitively
bother me about this... can't quite put my finger on it! I feel a bit
wary that the database's accuracy will depend on someone always
entering in the correct balance to square with the latest transaction
amount... what if they don't? I know it can be automated, but I don't
feel that comfy knowing that the database structure doesn't take care
of it, and it'll have to be some extra logic. Does this make sense?

Mark

PS Thanks for your reply. I hope you don't mind bearing with me
while I get my head around these new concepts!


Reply With Quote
  #50  
Old   
JOG
 
Posts: n/a

Default Re: Calculated value dilemma - 07-17-2008 , 06:33 AM



On Jul 16, 3:00 pm, Rainboy <mark.rain... (AT) gmail (DOT) com> wrote:
Quote:
On Jul 16, 1:13 pm, Bob Badour <bbad... (AT) pei (DOT) sympatico.ca> wrote:



Rainboy wrote:
Hi all

I am designing a database for my charity (we are a local special needs
charity) to replace our existing one, and my main goals are to make
the database accurate, easy to use, and able to expand (the current
database is not!).

The database will hold contact and membership details for about 300
families, staff/volunteers and other contacts, along with event
booking (we hold about 5 a week) and payment details.

So, for each family we need to see how much they owe, plus a full list
of all their transactions. I am considering having a transaction
table, which details every payment anyone has ever made.

IDEA 1
To follow normalisation rules I should avoid having calculated values
in the table, and I should therefore simply calculate the balance
whenever I need it by querying the table. I guess as the database
grows I would have to periodically 'consolidate' the balance to
maintain efficiency.

Where did you learn that was part of a normalization rule? It's just
plain wrong.

However, I see each updated balance as a snapshot in time - when I
look back to figure out 'who paid what when', I want to be 100%
confident that the database will return the same balance it would have
returned at the time. If a rogue entry were to somehow find its way
into the table, it would mess all the balances up...

Historical data should accurately reflect the history. What if a
calculation changes? What if a calculation depends on the instantaneous
value of some attribute where no history is stored? As a hypothetical
situation, suppose families with 5 or more kids get a special discount.
When baby #5 is born, the family doesn't suddenly get a discount on all
their past transactions.

IDEA 2
As keeping historically accurate info is important, 'hard-coding' the
balance in the table seems to me like it might be the most appropriate
solution, even though it breaks the normalisation rules.

Exactly which normal form do you suppose it violates?

Any suggestions would be greatly appreciated!

Mark

PS I've never designed a database before, so please let me know if
I'm completely barking up the wrong tree!

I think you have been misinformed. Where are you getting your information?- Hide quoted text -

- Show quoted text -

Hmmmm...

Well, I had assumed that the table would be violating 3NF because the
calculated value of the balance would be dependent on the transaction
amount, which is not the primary key.
3NF is deprecated really. You should start at BCNF when normalizing.
Regards, J.

Quote:
Ah, I think I'm starting to understand... is historical data treated
differently because as soon as an entry is 'in the past', the balance
(at that time) no longer depends on the transaction amount, and it
does only depend on the primary key of transaction ID. So I just have
a balance column, and whenever I want someone's current balance, I
just query this historical table for the most recent entry? And I
won't be breaking any rules? Smooth.

Although (assuming I've got this right) something does intuitively
bother me about this... can't quite put my finger on it! I feel a bit
wary that the database's accuracy will depend on someone always
entering in the correct balance to square with the latest transaction
amount... what if they don't? I know it can be automated, but I don't
feel that comfy knowing that the database structure doesn't take care
of it, and it'll have to be some extra logic. Does this make sense?

Mark

PS Thanks for your reply. I hope you don't mind bearing with me
while I get my head around these new concepts!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.