![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm curious about best practices involving products, their pricing and modelling variable pricing for new versus "renewal" pricing. The main thing of interest is the temporal modelling required for recurrent billing. The products and pricing is fairly straightforward. I suppose you would need some sort of products_purchases table which would store all occurences of a product purchase. Then you could have either explicit prices based on the number of years the product was owned or some sort of percentage table indicating price changes as a function of years of ownership. All in all, most of this might be better done with stored procedures. Just brainstorming for ideas about how this sort of thing has been tackled in the past. |
|
Now, time to step out of abstract and into practical. A big mistake would be to have a "renewal product." For instance, if you were a domain registrar and you had a domain_registration product, the last thing you need is a domain_registration_renew product so that you can have separate prices for new versus renewal domains. Why? Because it is rigid and only expresses new versus renew whereas recurrence can have many degrees of depth based on years of renewing.... |
.
#3
| |||
| |||
|
|
'Discounts' means you have a single price for each product, and then a set of discounts which applied under certain conditions. So, as above, an 'on sale' discount, a 'preferred customer' discount, discounts specific to each customer, discounts for buying in bulk, etc. It boils down to much the same thing as the price lists approach, just expressed in different arithmetic. The discounts approach is intrinsically more flexible, |

|
The downside is that it may present a more complex mental model to your business users (content managers, merchandisers, or whatever you call them). |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Let me use a history table for price changes. The fact is that a price had duration. This is the nature of time and other continuums. So a basic history table looks like this in SQL/PSM CREATE TABLE PriceHistory (upc CHAR(13) NOT NULL -- industry standard REFERENCES Inventory(upc), price_prev_date DATE NOT NULL, price_start_date DATE DEFAULT CURRENT_DATE NOT NULL, price_end_date DATE, -- null means current price CHECK(price_start_date < price_end_date), CHECK (price_start_date = price_prev_date + INTERVAL 1 DAY), -- prevents gaps |
#6
| |||
| |||
|
|
How? |
#7
| |||
| |||
|
|
Let me use a history table for price changes. The fact is that a price had duration. This is the nature of time and other continuums. So a basic history table looks like this in SQL/PSM CREATE TABLE PriceHistory (upc CHAR(13) NOT NULL -- industry standard REFERENCES Inventory(upc), price_prev_date DATE NOT NULL, price_start_date DATE DEFAULT CURRENT_DATE NOT NULL, price_end_date DATE, -- null means current price CHECK(price_start_date < price_end_date), CHECK (price_start_date = price_prev_date + INTERVAL 1 DAY), -- prevents gaps PRIMARY KEY (upc, price_start_date), item_price DECIMAL (12,4) NOT NULL CHECK (item_price >>> 0.0000), etc.); [prevent's gaps] How? Opps! You need a REFERENCES to the history table assure that the price_prev_date is also used as a price_end_date. SQL Serrver is bad about cycles, however. |
#8
| |||
| |||
|
|
UPC char(13) seemed odd but then I realized space paddeding for shorter codes (like ean-8) is not a problem and using a fixed-width column is probably more efficient. If needed a check can be added to ensure only valid codes are entered. |

![]() |
| Thread Tools | |
| Display Modes | |
| |