title: PL/SQL Check constraint: value on one column depends on another column
body: <p>Using PL/SQL, I'm building a table containing config which defines the distribution of samples into 2 different sets based on ratio. It has 4 columns: sample_type, set_1, set_2, ratio (percentage of samples going to set_1). For example, if a row is ('walk', 'left', 'right', 50), it means for samples whose type is 'walk', 50% of them goes 'left' while the rest goes 'right'.</p>
  
  <p>I want to add a check constraint which makes sure that set_2 is null if only ratio is 100, i.e. 100% of sample goes to set_1. I try something like:</p>
  
  <pre><code>ALTER TABLE CONFIG
  ADD CONSTRAINT CHK
  CHECK (
      NOT EXISTS (SELECT 1 FROM CONFIG WHERE SET_2 IS NULL AND RATIO &lt;&gt; 0)
  )
  </code></pre>
  
  <p>However, Oracle doesn't allow sub-query in check. So, is there another way to add a check constraint for this situation?</p>
  
  <p>Thank you</p>