foreign keys deppending on two different tables in mysql

  • From: "Marlon Brandão de Sousa" <splyt.lists@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Tue, 18 Sep 2007 16:30:56 -0300

Hello,
I have this situation:
Table a has an id and a name field
Table b has an id and a name field
Table c has an id field, an external code field and a name field
The external code field of table c must be an existing id in table a
or in table b, thus it is a foreign key.
I do know, for example, how to make the external code field from table
c deppend on the id field of table b ... what I don't know is if it is
possible to make it refer to the id field from table b or to the id
field of table a.
I know this would cause some ambiguity in a ondelete rule, but what I
need is to guarantee that the external field from table c will accept
only values present on table a or on table b.
Do you know if this is possible and, if it is, how to do it in the
mysql database?
Sure I can implement this in the code but I was woundering if it is
possible to build this kind of rule in the database.
Thanks
Marlon
-- 
When you say "I wrote a program that crashed Windows," people just
stare at you blankly and say "Hey, I got those with the system, for
free."
Linus Torvalds
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: