Popular recipes tagged "antagonisms"http://code.activestate.com/recipes/tags/antagonisms/2012-01-05T08:58:40-08:00ActiveState Code RecipesSimple Knowlegde Database (Python)
2012-01-05T08:58:40-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/577975-simple-knowlegde-database/
<p style="color: grey">
Python
recipe 577975
by <a href="/recipes/users/4174477/">Thomas Lehmann</a>
(<a href="/recipes/tags/antagonisms/">antagonisms</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/knowledge/">knowledge</a>, <a href="/recipes/tags/opposites/">opposites</a>, <a href="/recipes/tags/relationships/">relationships</a>).
Revision 2.
</p>
<p><strong>What's the idea?</strong></p>
<ul>
<li>The idea is to be able to ask more successful questions than data provided.</li>
<li>To have a kind of simple database</li>
</ul>
<p><strong>How is this done?</strong></p>
<ul>
<li>A releationship is always though as a from of older/younger or bigger/smaller. You have to define those opposite meanings by calling 'defineAntagonism'</li>
<li>After this you can define a relationship by calling 'defineRelationship' using one of the opposite meanings and two ... I say names (can be persons or objects)</li>
<li>When you define that somebody/someting is bigger than somebody/something else then you implicitly provide two information (bigger <-> smaller)</li>
<li>Also when defining - more commonly explained - that A > B and B > C then also A > C and C < A. </li>
<li>That's the main logic implemented by this python code.</li>
</ul>
<p><strong>Special notes</strong></p>
<ul>
<li>We have to avoid inconsistent data; when it is defined that A > B then you are not allowed to say that B > A.</li>
<li>We have to sort relations because they build up - I name it like this - a dependency chain. When a query checks for A > C but A > B and B > C is defined only we need an order for searching.</li>
</ul>