Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8255907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:41:23+00:00 2026-06-08T01:41:23+00:00

I have to make some changes to an e-commerce system to add some additional

  • 0

I have to make some changes to an e-commerce system to add some additional information and wanted to take the opportunity to possibly make some improvements and make it more flexible. When a customer places an order, we have to store several items of information with each item ordered; for example, the product price, the shipping price, the tax collected, any adjustments that were made.

I am debating if these fields should be stored discretely, such as (simplified example):

ORDER_LINE_ITEM
    OrderLineItemID
    ProductID
    Qty
    Price
    Shipping
    Handling      
    SalesTax
    Adjustment

For example, I could then calculate the total price the customer paid:

SELECT Qty*(Price+Shipping+Handling+SalesTax) As TotalCollected FROM ORDER_LINE_ITEM

Or if I should use a more indirect structure:

ORDER_LINE_ITEM
    OrderLineItemID
    ProductID
    Qty

ORDER_LINE_ITEM_ENTRIES
    OrderLineItemEntryID
    OrderLineItemID
    EntryType
    Value

For example:

1 | 1 | Price      | $10
2 | 1 | Shipping   | $5
3 | 1 | Handling   | $1
4 | 1 | SalesTax   | $1
5 | 1 | Adjustment | -$3.50

The advantage with this is that I can store additional information later on without altering the table schema. However retrieving the information and running reports becomes more complicated and slower.

Is there a best practice for storing this information in order/invoice databases?

Thanks in advance,

Dan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:41:25+00:00Added an answer on June 8, 2026 at 1:41 am

    I’d do a mixed approach, having both:

    ORDER_LINE_ITEM
        OrderLineItemID
        ProductID
        Qty
        Price
        Shipping
        Handling      
        SalesTax
        Adjustment
        Extras
    
    ORDER_LINE_ITEM_ENTRIES
        OrderLineItemEntryID
        OrderLineItemID
        EntryType
        Value    
    

    And then doing

    SELECT Qty*(Price+Shipping+Handling+SalesTax+Extras) As TotalCollected FROM ORDER_LINE_ITEM
    

    Then you can work most of the time with a single table, but if you need to search for the details of an item (or add new things that affect the price), you can do it (using the extra field).

    In another topic, I’d consider if all those fields should really be on ORDER_LINE_ITEM. I don’t know your business, but in the ones I know, the Shipping, Handling and even price is calculated over the whole order, not on just one item (And it’s not always possible to split it into separated items). It’s also pretty common to have an “Admin” user or password, who can come and sell whatever he wants, inputting arbitrary fields for everything, and ignoring all normal business rules. So you might consider doing something like:

    ORDER_LINE_ITEM
        OrderLineItemID
        OrderId
        ProductID
        Qty
    
    ORDER
        OrderId
        ItemsTotalPrice
        Shipping
        Handling
        SalesTaxes
        Adjusment
        FinalPrince
    

    You could create a details table to specify how the values of the order (taxes, shipping, etc..) were created…

    In general I’ve found that the best approach is to have an entity which has the final information of all the order (or operation), and then additional sub-entities that specify how the “total” values were calculated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to make some changes in a small system that stores data in
I have a modal dialog showing up and the user can make some changes
I have and old django site (0.97-pre-SVN-7457) and I'm about to make some changes
I'm dealing with an annoying problem. I have to make some changes to a
I have a mirrored database and I need to make some changes to it.
I was working on my home server remotely and wanted to make some changes
I have xml-file. I need to read it, make some changes and write new
I have this VB.Net 1.1 project that I have to make some changes to.
Since the launch of IOS 5, I have had to make some changes to
I have an object, I make some changes to it, but I don't want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.