1

I need help with coding something. I'm trying to design a system that will allow users to setup rules for the system to process (similar to email processing rules, in a way). When I receive a chunk of data (in this case, it is a object that has properties with values related to the client system's hostname, OS version, etc.) I want the user to be able to create a criteria like "when the hostname equals 'somehost' or the OS version is greater than 6, etc.

The table I have so far has a record ID, a column for holding the name of the value I'm checking (like the property name, e.g. object.Hostname stores as "Hostname"), a two character code for the operator (EQ, NE, GT, etc), the value to compare against and a foreign key value.

I don't have a warm fuzzy about it, though. Am I going down the right path? I wanted the matching to be flexible. I'm visualizing putting the class properties in a dropdown so that the user can select the property, type in a search value and select the criteria. Thoughts?

Thanks!

asked May 16, 2013 at 19:20
2
  • I don't have experience with it myself (and it might be overkill for your situation), but I've considered using the Rules Engine in Windows Workflow Foundation for a similar task. You might take a look at it. Commented May 22, 2013 at 20:48
  • I also highly recommend this article. Although it is ostensibly about another problem domain (web form validation), the section on Rules Engines is quite enlightening. Commented May 22, 2013 at 21:17

1 Answer 1

1

Your design is correct. I assume that:

  • your ID is not set to auto increment, because it would mean, that it is not possible to add more than one condition to a certain rule
  • regarding the above point - you want to have more than one condition per rule.

I would suggest adding another column for the logical connection between each condition (OR;AND), unless ofcourse conditions in a rule are always OR or AND connected. I am assuming this because you wrote

when the hostname equals 'somehost' or the OS version is greater than 6, etc.

The architecture is not an overkill - it is minimalist and it will pay off! I would have normalized the tables even more:

  • Rules
  • Conditions
  • Operators
  • Properties
  • Values
  • and so on

Where i work, we have a custom rule engine exactly for such purposes and it is designed more or less the way you described it.

answered May 24, 2013 at 23:17
1
  • I like where this is going! Thanks for the encouragement. Commented May 28, 2013 at 17:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.