Best database structure to keep values that gets updated often









up vote
1
down vote

favorite












I currently am designing new system based on a legacy one, and am facing this problem regarding the database structure.



I have 4 tables which are SalesOrder and SalesOrderLine; DelivNote and DelivNoteLine. SalesOrderLine table consists of list of item that are ordered with its quantity and selling price. DelivNoteLine table will read data from SalesOrderLine table and create entries for the item that have been delivered. The delivery can be done partially, so i need to keep track of the delivered item and the outstanding item for each Sales Order.



For example, Sales Order X sold 4 qty of item A, then i make delivery note for 1 qty of item A, with a reference to Sales Order X. Where do i store the value of the 3 qty of the outstanding item.



Currently, the table structured like this



so_id, so_name, so_desc
3 SO-X XXX

soline_id, so_id, soline_quantity, sod_price, sod_outstanding_quantity
1 3 4 1.000 3

dn_id, dn_name, so_id, dn_desc
1 DN-A SO-X XXX

dnline_id, dn_id, dnline_quantity
1 1 1


This can works, but i heard that its better to calculate the outstanding quantity based on sum of dnline_quantity. Any suggestion?










share|improve this question

























    up vote
    1
    down vote

    favorite












    I currently am designing new system based on a legacy one, and am facing this problem regarding the database structure.



    I have 4 tables which are SalesOrder and SalesOrderLine; DelivNote and DelivNoteLine. SalesOrderLine table consists of list of item that are ordered with its quantity and selling price. DelivNoteLine table will read data from SalesOrderLine table and create entries for the item that have been delivered. The delivery can be done partially, so i need to keep track of the delivered item and the outstanding item for each Sales Order.



    For example, Sales Order X sold 4 qty of item A, then i make delivery note for 1 qty of item A, with a reference to Sales Order X. Where do i store the value of the 3 qty of the outstanding item.



    Currently, the table structured like this



    so_id, so_name, so_desc
    3 SO-X XXX

    soline_id, so_id, soline_quantity, sod_price, sod_outstanding_quantity
    1 3 4 1.000 3

    dn_id, dn_name, so_id, dn_desc
    1 DN-A SO-X XXX

    dnline_id, dn_id, dnline_quantity
    1 1 1


    This can works, but i heard that its better to calculate the outstanding quantity based on sum of dnline_quantity. Any suggestion?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I currently am designing new system based on a legacy one, and am facing this problem regarding the database structure.



      I have 4 tables which are SalesOrder and SalesOrderLine; DelivNote and DelivNoteLine. SalesOrderLine table consists of list of item that are ordered with its quantity and selling price. DelivNoteLine table will read data from SalesOrderLine table and create entries for the item that have been delivered. The delivery can be done partially, so i need to keep track of the delivered item and the outstanding item for each Sales Order.



      For example, Sales Order X sold 4 qty of item A, then i make delivery note for 1 qty of item A, with a reference to Sales Order X. Where do i store the value of the 3 qty of the outstanding item.



      Currently, the table structured like this



      so_id, so_name, so_desc
      3 SO-X XXX

      soline_id, so_id, soline_quantity, sod_price, sod_outstanding_quantity
      1 3 4 1.000 3

      dn_id, dn_name, so_id, dn_desc
      1 DN-A SO-X XXX

      dnline_id, dn_id, dnline_quantity
      1 1 1


      This can works, but i heard that its better to calculate the outstanding quantity based on sum of dnline_quantity. Any suggestion?










      share|improve this question













      I currently am designing new system based on a legacy one, and am facing this problem regarding the database structure.



      I have 4 tables which are SalesOrder and SalesOrderLine; DelivNote and DelivNoteLine. SalesOrderLine table consists of list of item that are ordered with its quantity and selling price. DelivNoteLine table will read data from SalesOrderLine table and create entries for the item that have been delivered. The delivery can be done partially, so i need to keep track of the delivered item and the outstanding item for each Sales Order.



      For example, Sales Order X sold 4 qty of item A, then i make delivery note for 1 qty of item A, with a reference to Sales Order X. Where do i store the value of the 3 qty of the outstanding item.



      Currently, the table structured like this



      so_id, so_name, so_desc
      3 SO-X XXX

      soline_id, so_id, soline_quantity, sod_price, sod_outstanding_quantity
      1 3 4 1.000 3

      dn_id, dn_name, so_id, dn_desc
      1 DN-A SO-X XXX

      dnline_id, dn_id, dnline_quantity
      1 1 1


      This can works, but i heard that its better to calculate the outstanding quantity based on sum of dnline_quantity. Any suggestion?







      sql-server database database-design normalization






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 16:18









      dimas bex

      61




      61



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250682%2fbest-database-structure-to-keep-values-that-gets-updated-often%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250682%2fbest-database-structure-to-keep-values-that-gets-updated-often%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党