I'm playing with some ideas. Basically I want a foreign key but I want the table that the key should be used to also be in the row. So that the foreign keys can refer to different tables. Generally you'd only be returning one result from any given query that needed to dereference this 'pointer'.
I know I could just store the table name and use two select statements to do it, inserting the result of the first select to get the table and key into the next call to index the right table, but can it be done with a single select on the database? What would the sql look like?
EDIT: Let me see if I can come up with an example. MediaTable ID | Name | Owner| Type | FKey
Mp3 ID | Artist | Album | Title | BitRate | Codec | Data
Movie ID | Title | Resolution | imdbUrl | AudioCodec | VideoCodec | Data
OK contrived but ... leta say I want to search the MediaTable for all Titles (in Mp3 or Movie tables) where MediaTable.Owner = "ekl" assuming FKey is the foreign key of the ID field. Can "MediaTable.type" select which table that FKey should apply to?
Yes, I know its not the best way to do this particular example, but its easier than explaining two larger projects where I would want this.