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?


  • 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. – kmote May 22 '13 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. – kmote May 22 '13 at 21:17

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.

  • I like where this is going! Thanks for the encouragement. – Darkwater23 May 28 '13 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.