Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Given that the badge criteria can be arbitrarily complex, I don't think you can store it in a database table broken down into "simple" data elements. Trying to write a "rules engine" that can handle arbitrarily complex criteria is going to take you down the path of basically re-writing all the tools that you have in your programming language.</p> <p>If you know in advance you want the badges limited to only certain fields (i.e. badges are only based off reputation or number of edits or something), then you can store those in a simple table like:</p> <pre><code>ReputationBadgeCriteria BadgeId BadgeName MinReputation </code></pre> <p>Alternatively, you could use some kind of DSL to write your "rules" but you end up having to also create a parser to parse the rules when you read them as well as something to execute these rules. Depending on the complexity you want in your DSL, this may not be a trivial task. This looks like the path you are going in your question with having a Criteria column (presumably plain text) that has something like "[Reputation] > 1000" or "[Posts] > 5" in it. You still have to parse and execute those rules and the complexity of writing something to do so is dependent on how complex you want those rules to be.</p> <p>I would recommend you read <a href="http://thedailywtf.com/articles/soft_coding.aspx" rel="noreferrer">these</a> Daily WTF <a href="http://thedailywtf.com/Articles/The_Enterprise_Rules_Engine.aspx" rel="noreferrer">articles</a> for information on why this approach leads to pain.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload