My idea is to use two entries (one containing the referenced table name and one containing the key in that table) in one table to reference one of several other tables.
The relevant parts of the table:
CREATE TABLE people
(
peopleid SMALLINT UNSIGNED auto_increment,
name VARCHAR(40) NOT NULL,
prevname VARCHAR(40),
role ENUM('Teacher', 'Mentor', 'Administrator'),
roleid SMALLINT UNSIGNED
)
Note:Teacher and Mentor are tables. If the person is an administrator, RoleID would be null.
I want the RoleID to be the foreign key referencing what ever table is referenced in the Role field. How do I do that?