Quantcast
Viewing all articles
Browse latest Browse all 60

Foreign Key - from same table and parent table

I have 2 tables.

First table is parent

COLLECTIONS_OF_MAPS

idtitle
50013Geological Map Series
50014Climate Map Series

Second table is a child (but whilst describing map layers, it also has entries that are more like group layers, like parents to child maps within the same table, so there is a recursion element here) - this is then realised in a treeview control in software, just for context purposes.

MAP_LAYERS

idparent_layer_idname
123350013Hillshade
122850013Cultural Data
123150013Rock Types
12351233Offshore Hillshade
12341233Onshore Hillshade
12291228World Cities
12301228World Countries
12451228World Rivers
12701231Sedimentary Rock
12711231Igneous Rock
12721231Metamorphic Rock

I have just shown an example for the first map collection - "Geological Map Series".

As you can see it the MAP_LAYERS parent_layer_id column references entries from BOTH tables; it's parent and itself.Can I create a foreign key rule to that references the ids of itself and or its parent table?


Viewing all articles
Browse latest Browse all 60

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>