title: SQL: Enforce cardinality with assertions
body: <p>To explain the diagram.</p>
  
  <p>Two entities: E1 &amp; E2</p>
  
  <p>Cardinality:</p>
  
  <p>-from E1 to E2 (through relation R): (6,50)</p>
  
  <p>-from E2 to E1 (through relation R): (3,5)</p>
  
  <pre><code> ______               ^              ______
  |  E1  |___(6,50)____/R\____(3,5)___|  E2  |
  |______|             \ /            |______|
                        v
  </code></pre>
  
  <p>I'm supposed to enforce cardinality but the book doesn't dive too much into ASSERTION details. 
  Would this be a correct way to enforce said cardinality?                      </p>
  
  <pre><code>CREATE ASSERTION assert
  CHECK ( (SELECT COUNT(E1.ID) FROM E1) &gt;= 6  AND 
          (SELECT COUNT(E1.ID) FROM E1) &lt;= 60 AND 
          (SELECT COUNT(E2.ID) FROM E2) &gt;= 3  AND 
          (SELECT COUNT(E2.ID) FROM E2) &lt;= 5 );
  </code></pre>