title: Table-agnostic Foreign Keys?
body: <p>First, I did read <a href="https://stackoverflow.com/questions/294969/sql-one-foreign-key-references-primary-key-in-one-of-several-tables">this StackOverflow question</a>, so no need to point me towards it.</p>
  
  <p>I'm working on a similar problem right now. Specifically, I have a database with an Auditing table that is used to store auditing info about other tables within the db. The basic form of this table is:</p>
  
  <p>ID, EntityID, EntityTypeID, ActionTypeID, DateTime</p>
  
  <p>Now, as you can guess, the generic nature of EntityID means that foreign key relationships to and from this table are tricky to manage, especially with you through an ORM system into the mix.</p>
  
  <p>Of course, the grunt-work solution is to do the required queries manually and use the ORM stuff where it works, which I'm fine with.</p>
  
  <p>However, the issue did raise the question in my mind as to whether or not there exists any RDBMS out there that allows for a Foreign Key relationship of the form: Table:ID to be defined.</p>
  
  <p>In other words, in such an RDBMS, the EntityTypeID column might contains values such as</p>
  
  <p>'TableA:1' and 'TableB:somekey'</p>
  
  <p>So...</p>
  
  <p>Is there any RDBMS which does this?</p>