title: Postgresql MATCH PARTIAL work around?
body: <p>I'm trying to work around Postgresql 8.4's lack of <code>MATCH PARTIAL</code>. I have the following schema:</p>
  
  <pre><code>[vehicles]
  lot_id | vin | source | year | make | model ...
    primary key ( lot_id, vin, source )
  
  [pictures]
  picture_id | lot_id | vin | url | sha1 ...
    primary key ( picture_id )
  </code></pre>
  
  <p>Now, what I want is a compound <code>FOREIGN KEY</code> that <code>REFERENCES</code> the <code>vehicles</code> table, such that it requires a <code>lot_id</code> and <code>vin</code> to exist in the <code>vehicles</code> table or the integrity constraint on the <code>pictures</code> table fails. The problem is this functionality is only available in <code>MATCH PARTIAL</code> which isn't implemented. Is there any other way to easily get this effect? Prior to the current schema iteration my vehicles table would have columns for each source <code>automated_make</code> <code>override_make</code> <code>vin_decode_make</code> this was getting to be a mess. But, it appears without <code>MATCH PARTIAL</code> I'll have to make a bigger change than I originally intended.</p>
  
  <p>I think I'll have to keep two compound <code>indexes</code> to achieve this.</p>
  
  <pre><code>[index]
  lot_id, vin
    primary key ( lot_id vin )
  </code></pre>
  
  <p>Maybe renaming <code>[vehicles]</code> to <code>[sources]</code> in the process; and, then forcing both <code>[vehicles]</code> and <code>[pictures]</code> to <code>MATCH FULL</code> against these this excessive table's <code>PRIMARY KEY</code>.</p>