Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would store the <code>OrQualifications</code> and <code>AndQualifications</code> as separate entities and keep them both as many-to-many references with the <code>Job</code> entity, this way you can differentiate the qualifications.</p> <p>To se if an applicant has the right qualifications, you check that ALL the qualifications in the <code>AndQualification</code> entity is met, AND that ANY of the qualifications in the <code>OrQualifications</code> entity is met.</p> <hr> <p>Edit:</p> <p>The above/initial answer was meant to satisfy a requirement of one list of qualifications that were required and another where at least one was required. To me this seems good enough, are you sure you really need nested qualifications? Trust me, making an application more complex than it needs to be is a bad idea.</p> <p><strong>Expression tree</strong><br> Nested qualifications is another beast and here is one suggested solution: The expression is stored as a full binary tree (a binary tree where each node has exactly 0 or 2 children). All nodes in this tree consists of operators AND or OR (&amp; or |) except for the leafs which will be the qualifications.</p> <p>Example expression:<br> (A | B &amp; C) | (D &amp; E)</p> <p>(The conversion from an expression to a tree is entirely dependent on how you input data, where the easiest would be to simply create the tree manually!)</p> <p>As a tree:<br></p> <pre> | / \ | & / \ / \ A & D E / \ B C </pre> <p>You have a number of different choices on how to persist this tree to a database, e.g:</p> <ul> <li>A hierarchial model where the absolut minimum is two columns, one Id and one ParentId. To fetch the tree you need a recursive query. This option can be pretty demanding for a relational database.</li> <li>Serialize the tree as e.g. xml (XmlSerializer) or json (json.NET) and save it as text.</li> </ul> <p>Personally I would choose the serializing option as you will always need full trees and it's easy to deserialize into a datastructure.</p> <p>Here is an example datastructure:</p> <pre><code>public class Node { public Node LeftChild { get; set; } public Node RightChild { get; set; } } class OperatorNode : Node { public bool IsAnd { get; set; } } class QualificationNode : Node { public bool IsQualificationMet { get; set; } } </code></pre> <p>Then you need a function that can parse this tree and output true or false:</p> <pre><code>public bool EvaluateNode( Node node ) { var qualificationNode = node as QualificationNode; if ( qualificationNode != null ) { return qualificationNode.IsQualificationMet; } var operatorNode = node as OperatorNode; if ( operatorNode.IsAnd ) { return EvaluateNode( node.LeftChild ) &amp;&amp; EvaluateNode( node.RightChild ); } return EvaluateNode( node.LeftChild ) || EvaluateNode( node.RightChild ); } </code></pre> <p><em>Disclaimer: This is so called quick and dirty code, please make something better.</em></p> <p><strong>Other options</strong><br> Look into System.Linq.Expressions.Expression. It can be used to programmatically build logic, so perhaps this is something you can use.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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