"Mulugeta Maru" <[EMAIL PROTECTED]> wrote:
> Can a field in one table be a foreign key of another table's field which is 
> also a foreign key of a third table?
> 

Sure.
For example:

mysql> CREATE TABLE t1 (
    ->   id int NOT NULL default '0',
    ->   PRIMARY KEY  (id)
    -> ) TYPE=InnoDB;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t2 (
    ->   id int NOT NULL default '0',
    ->   pid int default NULL,
    ->   PRIMARY KEY  (id),
    ->   KEY (pid),
    ->   FOREIGN KEY (pid) REFERENCES t1 (id)
    -> ) TYPE=InnoDB;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t3 (
    ->   id int NOT NULL default '0',
    ->   pid int default NULL,
    ->   PRIMARY KEY  (id),
    ->   KEY (pid),
    ->   FOREIGN KEY (pid) REFERENCES t2 (pid)
    -> ) TYPE=InnoDB;
Query OK, 0 rows affected (0.00 sec)



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to