I'm trying to work around Postgresql 8.4's lack of MATCH PARTIAL
. I have the following schema:
[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 )
Now, what I want is a compound FOREIGN KEY
that REFERENCES
the vehicles
table, such that it requires a lot_id
and vin
to exist in the vehicles
table or the integrity constraint on the pictures
table fails. The problem is this functionality is only available in MATCH PARTIAL
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 automated_make
override_make
vin_decode_make
this was getting to be a mess. But, it appears without MATCH PARTIAL
I'll have to make a bigger change than I originally intended.
I think I'll have to keep two compound indexes to achieve this.
[index]
lot_id, vin
primary key ( lot_id vin )
Maybe renaming [vehicles]
to [sources]
in the process; and, then forcing both [vehicles]
and [pictures]
to MATCH FULL
against these this excessive table's PRIMARY KEY
.