If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Orders & Articles database design

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-11-07, 07:02
Serruiki Serruiki is offline
Registered User
 
Join Date: Jun 2007
Posts: 2
Orders & Articles database design

Dear all,

I am designing a new database to manage orders and articles.
I have one table named "Articles", with the following fields:
ART_Code,
ART_Name,
ART_Supplier,
...,
ART_Price,
ART_Active,

It is supposed that some article prices increases every year, and, of course we need to keep old data, so Wich one of the following solutions you recomend?

a) Keep the current desing, so when a new price is provided we "deactivate" the article and create another one with the same data and different price

b) Remove the price from this table and Create a new one with the field Price on in
e.g "Article prices" fields
ARP_Code
ARP_Price


Thanks & Regards.
Reply With Quote
  #2 (permalink)  
Old 06-11-07, 07:43
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
solution b) lets you track only price changes, so solution a) seems more flexible

also, for solution b), you'll need an effective_from column

of course, you won't need an effective_to column, because that would require some shenanigans, possibly involving the dreaded NULL, so your best bet is simply to avoid that nonsense altogether, and just record the effective_from dates, and then the effective_to information can be gleaned from the fact that it's always the latest effective_from row that is current

easy peasy
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-11-07, 09:21
rajiravi rajiravi is offline
Registered User
 
Join Date: Apr 2004
Location: Toronto, Canada
Posts: 249
Quote:
Originally Posted by Serruiki
Dear all,

I am designing a new database to manage orders and articles.
I have one table named "Articles", with the following fields:
ART_Code,
ART_Name,
ART_Supplier,
...,
ART_Price,
ART_Active,

It is supposed that some article prices increases every year, and, of course we need to keep old data, so Wich one of the following solutions you recomend?

a) Keep the current desing, so when a new price is provided we "deactivate" the article and create another one with the same data and different price

b) Remove the price from this table and Create a new one with the field Price on in
e.g "Article prices" fields
ARP_Code
ARP_Price


Thanks & Regards.
With solution a, what does deactivating an article entail? What is the primary key of the article table? Will deactivation result in a violation of the primary key?

Ravi
Reply With Quote
  #4 (permalink)  
Old 06-11-07, 10:23
Serruiki Serruiki is offline
Registered User
 
Join Date: Jun 2007
Posts: 2
Dear R937,
Quote:
Originally Posted by r937
solution b) lets you track only price changes, so solution a) seems more flexible

also, for solution b), you'll need an effective_from column
Regarding B), yes, you are righ we should insert a ART_Date_from field.

Doing this change, would option B) be more suittable for a data base design?



Dear rajiravi,

Regariding you questions, by deactivating an article I meant change value of ART_Active from True to False.

Primary key would be ART_Code.
If we change price, another code would be created.

Eg

Code Name Supplier Price Active
----------------------------------
0001AA Art1 001 15.3 True
0002AA Art2 002 80.3 True

If I change price of Art1 to 15.9 then we will have

Code Name Supplier Price Active
----------------------------------
0001AA Art1 001 15.3 False
0002AA Art2 002 80.3 True
0001AB Art1 001 15.9 True

Orders made before price change, would not be affected.
Orders made after, would use the new code.

Thanks & Regards.
Reply With Quote
  #5 (permalink)  
Old 06-11-07, 10:57
rajiravi rajiravi is offline
Registered User
 
Join Date: Apr 2004
Location: Toronto, Canada
Posts: 249
Quote:
Originally Posted by Serruiki


Regarding B), yes, you are righ we should insert a ART_Date_from field.

Doing this change, would option B) be more suittable for a data base design?
Yes. Queries might be simpler if an effective_to date were also included. But that is your choice.

Quote:

Primary key would be ART_Code.
If we change price, another code would be created.

Eg

Code Name Supplier Price Active
----------------------------------
0001AA Art1 001 15.3 True
0002AA Art2 002 80.3 True

If I change price of Art1 to 15.9 then we will have

Code Name Supplier Price Active
----------------------------------
0001AA Art1 001 15.3 False
0002AA Art2 002 80.3 True
0001AB Art1 001 15.9 True

Orders made before price change, would not be affected.
Orders made after, would use the new code.
So what is the purpose of having th art_code column? It seems to act like a sequence generated ID column. The "name" column seems to be more meaningful.

Ravi
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On