title: Storing conditional logic expressions/rules in a database
body: <p>How can I store logical expressions using a RDBMS?</p>
  
  <p>I tag objects and would like to be able to build truth statements based on those tags.  (These might be considered as virtual tags.)</p>
  
  <p><strong>Tags</strong><br>
  <code>new</code><br>
  <code>for_sale</code><br>
  <code>used</code><br>
  <code>offer</code></p>
  
  <p><strong>Rule</strong><br>
  <code>second_hand_goods = (!new or used) and for_sale</code><br>
  <code>new_offer = new and offer</code><br>
  <code>second_hand_offer = second_hand_goods and offer</code></p>
  
  <ul>
  <li>Rules should be able to reference both tags and other rules.</li>
  <li>Schemas that can be easily accessed by hibernate would be preferrable.</li>
  <li>Preferably it will be possible to retrieve the entire rule in one select/call?</li>
  </ul>
  
  <p>How do you guys store expressions and business rules in your databases?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Update</strong><br>
  To be clear, the rules are not for use internally by the database but created and used by an external application that needs to persist these tags and rules.  Thanks.</p>