RE: foreign keys deppending on two different tables in mysql

  • From: "Sina Bahram" <sbahram@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 18 Sep 2007 15:35:21 -0400

You want to use the concept of a join:

I have to run, but google this really quick, and if you still don?t' have an
answer, then I'm sure Rodney will beat me to one.

Take care,
Sina
 

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Marlon Brandão
de Sousa
Sent: Tuesday, September 18, 2007 3:31 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: foreign keys deppending on two different tables in mysql

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

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: