Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

Multiple foreign key reference in a single field

sagavb@gmail.com's profile image sagavb@gmail.com posted 12 years ago in General Permalink
Hi Dudes,

I need to have a foreign key field that should refer from two tables. for an example,

table_a
--------
1 a_id primary key,
2 name

table_b
--------
1 b_id primary key,
2 name

table_c
-------
1 c_id
2 name
3 key_id (i.e, it should be foreign key from either table_a or table_b. it may have value of either table_a's id or table_b's id

Can any one of u help me to get this script to create table.

Thanks
Saga
ansgar's profile image ansgar posted 12 years ago Permalink
I don't think that's possible with an InnoDB hardcoded foreign key. There is no way to enter "table_a.a_id OR table_b.b_id" in a CREATE TABLE statement. Of course, you can do logic on your own, without InnoDB and real foreign keys.

Please login to leave a reply, or register at first.




Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.