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?
sql-server database database-design normalization
add a comment |
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?
sql-server database database-design normalization
add a comment |
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?
sql-server database database-design normalization
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
sql-server database database-design normalization
asked Nov 11 at 16:18
dimas bex
61
61
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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