LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-29-2004, 07:23 AM   #1
patpawlowski
Member
 
Registered: Mar 2003
Location: Centreville, Virginia
Distribution: Mandrak, Red Hat
Posts: 163

Rep: Reputation: 30
New Database program question


Next question:

I consider it a general rule to never store anything that you can calcualte. However there are a few consideration I can't seem to work out regarding tax rate and order total.

First I would assume that you would store a tax rate in your customer table, or at least a link to a tax table. If you do not store the actual rate with an order then after a tax rate change when you view an old order the calculated tax and total will be different. How should I deal with this?

Second, if you do not store the order total, how can you search the orders table based on total. Normally I design an interface where there would be a listing of customers, order, products, whatever and you select one. If I was to display a list of orders how can I show the order total without storing that total in the orders table? I supose I could designe a comples sql query that would calculate the totals every time but it just seems simpler to store that total.

What say the masses?

BTW, thanks for all the help guys.
 
Old 01-29-2004, 07:51 AM   #2
Strike
Member
 
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569

Rep: Reputation: 31
If the tax rate changes that often, then I would say that the amount of tax on something qualifies as something you can't calculate (without going to lengths to store tax rate history). Also, that rule only makes sense for when the calculation can be done relatively quickly. If it's a large, expensive calculation whose result will remain important for the life of the record/data, then storing it in the DB is actually probably a good idea.
 
Old 01-29-2004, 01:48 PM   #3
acjt
Member
 
Registered: Dec 2002
Location: Australia
Distribution: Gentoo
Posts: 161

Rep: Reputation: 30
Store it. Your situation warrants it. At least you think about it before just doing it!!
 
Old 01-29-2004, 02:36 PM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Take the tax rate out of the customer table. It will undo any effort on your part to use past sales to predict future sales. It will make difficult the task of making financial statements. The reason being that all attempts to use past sales in calculations will reflect the present tax rate, yielding incorrect results. Make a seperate tax rate table, with each tax rate uniquely identified by some kind of id. Put the tax rate id in the customer table. That way, when sales records are stored, they will include the id for the tax rate from the tax table. Calculations will address the appropriate tax rate. History is preserved. More importantly, you also avoid any possibllity of accusation of business or tax fraud resulting from incorrectly reported tax rates in your records.
 
Old 01-29-2004, 11:31 PM   #5
ter_roshak
Member
 
Registered: May 2001
Location: Everett, WA
Distribution: Gentoo, RedHat
Posts: 102

Rep: Reputation: 15
You may want to consider the simple fix of having a tax table with the related dates which those tax rates are effective for, then you can use the date that you have stored with the transaction to determine which tax rate to use. With this solution you are more efficient than relating each transaction to a tax table directly with a key.

-Josh
 
  


Reply



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

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Which database program silkmaze Linux - Software 1 10-18-2005 06:07 PM
sms program and database in linux web program in windows.. does not see each other.. keikun_naruchan Programming 0 07-06-2005 01:40 AM
database connectivity through C program junaid18183 Programming 1 06-11-2005 05:13 PM
COnnect Oracle Database in Linux by C++ program!! nelnel Linux - Software 4 05-24-2005 10:13 PM
Database modelling program RecoilUK Linux - General 1 08-07-2001 05:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration