title: 'for all' Queries in sql
body: <p>In class, professor said that SQL language does not provide 'for all' operator.
  In order to use 'for all' you have to use 'not exist( X except Y)'</p>
  
  <p>At this point, I can't figure out why 'for all' is same meaning as 'not exist( X except Y)'</p>
  
  <p>I give you example relation:  </p>
  
  <ul>
  <li>course (<strong><em>cID</em></strong>,title,deptName,credit),  </li>
  <li>teaches (<strong><em>pID,cID,semester,year</em></strong>,classroom),  </li>
  <li>student (<strong>sID</strong>,name,gender,deptName)</li>
  </ul>
  
  <p>Q: Find all student names who have taken all courses offered in 'CS' department</p>
  
  <p>The answer is: </p>
  
  <pre><code>Select distinct 
    S.sid, S.name 
  from 
    student as S 
  where 
    not exists (
      (select cID from course where deptName = 'CS') 
      except
      (select T.cID from takes as T where S.sID = T.sID)
    );
  </code></pre>
  
  <p>Can you give me specific explain about that?</p>
  
  <p>ps. Sorry for my English skill </p>