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!
Suggestions on how can I implement a generic matching system for users?
rules engine
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 ruleregarding 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:RulesConditionsOperatorsPropertiesValuesand so onWhere i work, we have a custom rule engine exactly for such purposes and it is designed more or less the way you described it.