Results 1 to 3 of 3

Thread: Where should calculations in SQL-table be placed ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: Where should calculations in SQL-table be placed ?

    Do you have some ideas how this is done the right way?
    1) For general, do not store results of such trivial computation (a+b) in database, save only the values needed for computing them. I don't see a point in keeping it.
    2) You can save total values of VAT and price, this way you'll need to query just for one record to get total value of invoice, instead of querying for all invoice entries and add the prices. You are likely to do something like asking for a total income / VAT for a given day (or customer), keeping those values could help.
    3) Maybe better would be to use a QSpinBox for quantity, this seems more natural to me. And maybe use a QLabel (or other non-editable widget) for total value + VAT, its not meant to be edited by users directly. Having all ui input items connected to a slot that refreshes the result seems ok. This may seem trivial but always validate user input before pushing data into database, this can save you some troubles.

  2. The following user says thank you to stampede for this useful post:

    homerun4711 (20th January 2011)

Similar Threads

  1. Edit table for my own table-widget
    By MasterMatrix in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2010, 07:05
  2. Replies: 5
    Last Post: 3rd April 2010, 04:07
  3. complex calculations with qt
    By gt.beta2 in forum Newbie
    Replies: 5
    Last Post: 7th February 2009, 23:55
  4. Table Widget Vs. Table View
    By winston2020 in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2008, 09:56
  5. Replies: 9
    Last Post: 21st June 2007, 10:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.