Never create multiple tables for storing similar information.
Suppose, you are going to make an inventory software for a shop where you will need to store purchase, sales and transfer information. You have two choices.
One is to create multiple tables for "purchase", "sales" and "transfer" information.
Second is to make a common table for every transaction of products for all of the given type of transactions.
Second is better.
Example:
Bad Practice
table: purchase (pur_id, date, order_by)
table: sales (sales_id, date, order_by)
table: transfer (tr_id, date, order_by)
Best Practice
table: orders (id, date, order_by, order_type)
(Here, bracketed elements are the names of attributes or fields of the table.)
Suppose, you are going to make an inventory software for a shop where you will need to store purchase, sales and transfer information. You have two choices.
One is to create multiple tables for "purchase", "sales" and "transfer" information.
Second is to make a common table for every transaction of products for all of the given type of transactions.
Second is better.
Example:
Bad Practice
table: purchase (pur_id, date, order_by)
table: sales (sales_id, date, order_by)
table: transfer (tr_id, date, order_by)
Best Practice
table: orders (id, date, order_by, order_type)
(Here, bracketed elements are the names of attributes or fields of the table.)
No comments:
Post a Comment