Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Modeling Order Extensions

 
   Database Help (Home) -> Technology and Theory RSS
Next:  Boolean expressions evaluation  
Author Message
Lars Tackmann

External


Since: Mar 27, 2008
Posts: 3



(Msg. 1) Posted: Fri Oct 17, 2008 4:05 am
Post subject: Modeling Order Extensions
Archived from groups: comp>databases>theory (more info?)

Hi all

I have a leasing system where customers rent items and pay them of
over time. This is somewhat different from the usual order/order_line
design since in this case the customer only have one order which is
then modified via extensions (i.e. as he extends the leasing periods,
lease more/other products...). Consider the following use case:

1: A customer purchases item I1 at price P1 and item I2 with price P2
2: This results in order number O1 with order lines that references
O1, item I1 and I2 and prices P1 and P2.
3: The total price is calculated and saved in O1. The price is payed
off in 24 monthly payments.

After some time the customer purchases more of Item I1 now priced P3
(the item got cheaper). The question is how do I best model such order
extensions ?. One way could be this:

orders -> orders_version -> order_items

so when the initial order is created we have order O1 with version V1
(referenced in the order_items table which contains products, quantity
and a copy of the current price), later we add version V2 to O1
containing the extra items.

Another possibility would be to freeze price changes (disable updates)
and then simply reference the prices directly:

orders -> orders_items -> product_prices

thereby forcing all products to have a collection of prices, with each
price being valid for a different period of time.

is there other possibilities for some neat relational design for this
problem ?. By the way is there any books that goes through design
options for real life database problems such as this ? (similar to
Martin Fowlers "Analysis Patterns" book).

Thanks in advance.

 >> Stay informed about: Modeling Order Extensions 
Back to top
Login to vote
soren.bendixen

External


Since: Oct 17, 2008
Posts: 1



(Msg. 2) Posted: Fri Oct 17, 2008 5:57 am
Post subject: Re: Modeling Order Extensions [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Oct 17, 1:05 pm, Lars Tackmann wrote:
> Hi all
>
> I have a leasing system where customers rent items and pay them of
> over time. This is somewhat different from the usual order/order_line
> design since in this case the customer only have one order which is
> then modified via extensions (i.e. as he extends the leasing periods,
> lease more/other products...). Consider the following use case:
>
> 1: A customer purchases item I1 at price P1 and item I2 with price P2
> 2: This results in order number O1 with order lines that references
> O1, item I1 and I2 and prices P1 and P2.
> 3: The total price is calculated and saved in O1. The price is payed
> off in 24 monthly payments.
>
> After some time the customer purchases more of Item I1 now priced P3
> (the item got cheaper). The question is how do I best model such order
> extensions ?. One way could be this:
>
> orders -> orders_version -> order_items
>
> so when the initial order is created we have order O1 with version V1
> (referenced in the order_items table which contains products, quantity
> and a copy of the current price), later we add version V2 to O1
> containing the extra items.
>
> Another possibility would be to freeze price changes (disable updates)
> and then simply reference the prices directly:
>
> orders -> orders_items -> product_prices
>
> thereby forcing all products to have a collection of prices, with each
> price being valid for a different period of time.
>
> is there other possibilities for some neat relational design for this
> problem ?. By the way is there any books that goes through design
> options for real life database problems such as this ? (similar to
> Martin Fowlers "Analysis Patterns" book).
>
> Thanks in advance.

You make sure to store item price at order item lines at the time
where the customer picks a item. That way the price of the item can be
printed now and a year after and finally be billed at the price that
the customer accepted. Price will change over time but your item price
is fixed. A good idea is newer to reopen an order but instead make a
new one.
This way the logic will work

 >> Stay informed about: Modeling Order Extensions 
Back to top
Login to vote
Bob Badour

External


Since: Jan 15, 2008
Posts: 1017



(Msg. 3) Posted: Fri Oct 17, 2008 8:25 am
Post subject: Re: Modeling Order Extensions [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Lars Tackmann wrote:

> Hi all
>
> I have a leasing system where customers rent items and pay them of
> over time. This is somewhat different from the usual order/order_line
> design since in this case the customer only have one order which is
> then modified via extensions (i.e. as he extends the leasing periods,
> lease more/other products...). Consider the following use case:
>
> 1: A customer purchases item I1 at price P1 and item I2 with price P2
> 2: This results in order number O1 with order lines that references
> O1, item I1 and I2 and prices P1 and P2.
> 3: The total price is calculated and saved in O1. The price is payed
> off in 24 monthly payments.
>
> After some time the customer purchases more of Item I1 now priced P3
> (the item got cheaper). The question is how do I best model such order
> extensions ?. One way could be this:
>
> orders -> orders_version -> order_items
>
> so when the initial order is created we have order O1 with version V1
> (referenced in the order_items table which contains products, quantity
> and a copy of the current price), later we add version V2 to O1
> containing the extra items.
>
> Another possibility would be to freeze price changes (disable updates)
> and then simply reference the prices directly:
>
> orders -> orders_items -> product_prices
>
> thereby forcing all products to have a collection of prices, with each
> price being valid for a different period of time.
>
> is there other possibilities for some neat relational design for this
> problem ?. By the way is there any books that goes through design
> options for real life database problems such as this ? (similar to
> Martin Fowlers "Analysis Patterns" book).
>
> Thanks in advance.

There are two ways of looking at your stated problem: 1) temporal data
and 2) proper normalization of historical records.

Lorentzos', Date's & Darwen's _Temporal Data and the Relational Model_
give a theory based solution for solving the temporal data problem;
however, the solution relies on interval type generators which do not
exist yet in any commercial product.

Historical data or audit trails have different functional dependencies
from the tables where their values originated at different points in
time. It's simply a matter of not declaring constraints that do not hold.
 >> Stay informed about: Modeling Order Extensions 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Database modeling question - Hi I'm trying to model a database but I'm having troubles sorting out my ideas. Can anyone help? I have "Airplanes" & "Weapons" (and specialized weapons such as Guns, Bombs and so on that "extend" from Weapons). What I ...

Modeling Data for XML instead of SQL-DBMS - If working on a software project where all data are persisted in XML documents and not in an SQL-DBMS, the tools would not require that the data model be in 1NF or the use of the SQL NULL. How would an excellent logical data model designed for this XML....

Data modeling for a multi-company product - One feature of some ERP and other software application systems is the ability for the customer site to indicate in the setup which attributes are required and which are not related to the various data entry "screens." So, customer A might cons...

Order details table reference live data - This is a real pickle. My company's web application offers a lot of ways to order products, so there are quite a few Order/OrderDetail tables in the db (one for every type of order). The problem is that the Order Detail tables aren't denormalized,..

Foreign key constraint delete fire order - Hi! I feel that DELETE trigger associated with Referential Integrity (RI) constraints should be fired by BEFORE DELETE event. In order to avoid cross posting, please refer to: ..
   Database Help (Home) -> Technology and Theory All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]