Re: Business Rules

From: topmind <>
Date: Sat, 29 Mar 2008 00:14:02 -0700 (PDT)
Message-ID: <>

Lars Tackmann wrote:
> Hi
> This is a recurring question here, but I have read through the archive
> and failed to find a answer so here goes.
> Consider the following use cases:
> - When a customer purchases product A he automatically gets product B
> - Product C can only be bought with product A (either if you have A
> already or in the same order)
> - Product D cannot be bought with C
> - When you purchase X number of product type E then you can not
> purchase more than Y of product type F
> - A certain product combination (number and types) should yield a
> discount.
> as seen there exists the concept of a single product and that of a
> product type (family of products), the business rules should be able
> to work on both single products and on product types. The question now
> is how best to deal with such rules from a DB point of view, is there
> a relational design general enough to cope with such rules ? or do I
> have to resolve to stored procedures and constraints ?.
> I am not on the lookout for a complete solution, I simply see allot of
> business rules like the ones defined above, but never a clean
> solution to maintaining them (perhaps a DSL or a rule engine is the
> way to go).
> Any feedback will be greatly appreciated.

I would suggest creating a little sub-language via subroutines for validation for a given product or order. Example:

IF (anyOf("footware,halloween,product4625") Or allOf("shirts,coupon")) And anyOf("discount4") THEN logError("Federal law 234X prohibits type-4 discounts on these items per trade fight with France")

The end result will look like some kind of Boolean expression and/or set-oriented language, perhaps with some string list parsing capabilities. Whether it's possible to do this easily with SQL, I'd have to look at your actual system.

This is in conjunction with a many-to-many table for product classifications.

> --
> Yours sincerely
> Lars Tackmann

-T- Received on Sat Mar 29 2008 - 08:14:02 CET

Original text of this message