Symmetric and Asymmetric Relationships
Date: Thu, 18 Nov 2004 21:39:17 -0500
Message-ID: <lv2072-dif.ln1_at_pluto.downsfam.net>
Sometimes we encounter a mismatch between symmetric and asymmetric relationships.
For instance, a foreign key is asymmetric, its operation are not the same in both directions. A join in a SELECT statement however is symmetric, you can specify the operation in either direction and get the same result.
This can be a problem when you need to validate asymmetric data against symmetric. Data entered into the more lax situation may be reversed so that it fails to match into the stricter source. For example, a data dictionary specifies that TAB_CHILD has a foreign key against TAB_PARENT, but a user defining a view puts in TAB_PARENT joining to TAB_CHILD.
The answer I came up with is to produce a UNION view of the foreign keys table with itself, where the 2nd copy has the keys reversed, something like this:
SELECT table_id,table_id_par FROM foreign_keys
UNION ALL
SELECT table_id_par,table_id FROM foreign_keys
I can then validate against this "loosened" table, and either CHILD->PARENT or PARENT->CHILD will both validate OK, and Bob's your uncle.
Has anyone else run into situations with the mix of symmetric and asymmetric data? Any solutions you care to share?
-- Kenneth Downs <?php echo "sig block. no biggie." ?>Received on Fri Nov 19 2004 - 03:39:17 CET
