tags:

views:

379

answers:

2

I would like to design a rules based database engine within Oracle for PeopleSoft Time entry application. How do I do this?

+1  A: 

I haven't tried this myself, but an obvious approach is to use Java procedures in the Oracle database, and use a Java rules engine library in that code.

Try:

http://www.oracle.com/technology/tech/java/jsp/index.html

http://www.oracle.com/technology/tech/java/java_db/pdf/TWP_AppDev_Java_DB_Reduce_your_Costs_and%20_Extend_your_Database_10gR1_1113.PDF

and

http://www.jboss.org/drools/

or

http://www.jessrules.com/

--

Basically you'll need to capture data events (inserts, updates, deletes), map to them to your rulespace's events, and apply rules.

+2  A: 

A rules-based system needs several key components: - A set of rules defined as data - A set of uniform inputs on which to operate - A rules executor - Supervisor hierarchy

  1. Write out a series of use-cases - what might someone be trying to accomplish using the system?
  2. Decide on what things your rules can take as inputs, and what as outputs
  3. Describe the rules from your use-cases as a series of data, and thus determine your rule format. Expand 2 as necessary for this.
  4. Create the basic rule executor, and test that it will take the rule data and process it correctly
  5. Extend the above to deal with multiple rules with different priorities
  6. Learn enough rule engine theory and graph theory to understand common rule-based problems - circularity, conflicting rules etc - and how to use (node) graphs to find cases of them
  7. Write a supervisor hierarchy that is capable of managing the ruleset and taking decisions based on the possible problems above. This part is important, because it is your protection against foolishness on the part of the rule creators causing runtime failure of the entire system.
  8. Profit!

Broadly, rules engines are an exercise in managing complexity. If you don't manage it, you can easily end up with rules that cascade from each other causing circular loops, race-conditions and other issues. It's very easy to construct these accidentally: consider an email program which you have told to move mail from folder A to B if it contains the magic word 'beta', and from B to A if it contains the word 'alpha'. An email with both would be shuttled back and forward until something broke, preventing all other rules from being processed.

I have assumed here that you want to learn about the theory and build the engine yourself. alphazero raises the important suggestion of using an existing rules engine library, which is wise - this is the kind of subject that benefits from academic theory.

Phil H