Multiple Foreign Keys

2004-07-22 Thread Roy Harrell
Can a child table have multiple foreign key references linking its records to two or more parent tables? Can a parent table also be a child table? That is, can a parent table have a foreign key that links it to another table? I setting up my tables as INNODB types. Thanks, Roy Harrell --

Re: Multiple Foreign Keys

2004-07-22 Thread SGreen
The answer is yes to all of your questions. Just as an example, I have a table in one of my databases that is a child to nine other tables and is the parent to two. Just remember that any child table columns participating in a FK relationship must also be indexed (or the first column listed in

Re: Multiple Foreign Keys

2004-07-22 Thread Josh Trutwin
On Thu, 22 Jul 2004 12:14:58 -0400 Roy Harrell [EMAIL PROTECTED] wrote: Can a child table have multiple foreign key references linking its records to two or more parent tables? yes - something like: CREATE TABLE child ( p1_id INT, p2_id INT, INDEX p1_id_ind (p1_id), INDEX

re: Multiple foreign keys?

2003-03-08 Thread Egor Egorov
On Saturday 08 March 2003 02:27, Daevid Vincent wrote: Can I have multiple foreign keys in a table? Like this... I ask because I can't seem to get it to work. Errno: 150. Yes, you can. Check that all tables are InnoDB, that columns have the same type and so on .. CREATE TABLE `dept_table

Multiple foreign keys?

2003-03-07 Thread Daevid Vincent
Can I have multiple foreign keys in a table? Like this... I ask because I can't seem to get it to work. Errno: 150. CREATE TABLE `dept_table` ( `dept_id` mediumint(8) unsigned NOT NULL auto_increment, `dept_timestamp` timestamp(14) NOT NULL, `dept_company_table_id` mediumint(8) unsigned

Query syntax: multiple foreign keys

2002-01-12 Thread =James Birkholz=
I'm new to the list, to mysql and to dynamic website programming. I'm not new to programming, had my nose in Access97 for the last few years, off and on. So I'm used to being coddled with sql and can't find a syntax that works for this situation: (I'm using phpMyAdmin to work with the database

Re: Query syntax: multiple foreign keys

2002-01-12 Thread DL Neil
James, I'm new to the list, to mysql and to dynamic website programming. I'm not new to programming, had my nose in Access97 for the last few years, off and on. So I'm used to being coddled with sql and can't find a syntax that works for this situation: (I'm using phpMyAdmin to work with

RE: Query syntax: multiple foreign keys

2002-01-12 Thread =James Birkholz=
In a message dated 1/12/02 10:48:45 AM Central Standard Time, [EMAIL PROTECTED] writes: ---snip--- SELECT A.Name, B.Name, P.ID FROM Persons P LEFT JOIN QualityA A USING(A_ID) LEFT JOIN QualityB B USING(B_ID) WHERE P.ID = thatGuy; ---snip--- That doesn't work, get an error as it

RE: Query syntax: multiple foreign keys

2002-01-12 Thread Roger Baklund
* =James Birkholz= In a message dated 1/12/02 10:48:45 AM Central Standard Time, [EMAIL PROTECTED] writes: ---snip--- SELECT A.Name, B.Name, P.ID FROM Persons P LEFT JOIN QualityA A USING(A_ID) LEFT JOIN QualityB B USING(B_ID) WHERE P.ID = thatGuy; ---snip--- That doesn't

RE: Query syntax: multiple foreign keys

2002-01-12 Thread Roger Baklund
I'm going to send direct from the programming computer, using a different e-mail address. Ok, I reply to the list, but CC to you. Think I found your problem... I did find that I had one invalid foreign key value in table A, but my problem remains... I tried this: Database PosenL running

Re: Query syntax: multiple foreign keys

2002-01-12 Thread =James Birkholz=
I'm going re-post this query. Roger Backlund had been attempting to help me but I've either stumped him or he's busy having a life :) Besides, my first posting had several problems, since I was working from memory. Finally, in the process of preparing this query, I found a small change that

RE: Query syntax: multiple foreign keys

2002-01-12 Thread =James Birkholz=
Wow, our posts crossed in the mail and you suggested the same approach that I discovered independently! (Great minds think alike, right?) I'm working remotely, the server is many states away, and I don't have a local developement environment. I'm modifying the actual working site, though I try to