MySqlTalk.com  

Go Back   MySqlTalk.com > MySQL > Database Design
User Name
Password
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread
Old 02-23-2006, 11:51 PM   #1
jstephens
Junior Member
 
Join Date: Feb 2006
Posts: 5 jstephens is on a distinguished road
Foreign Key too Two Tables

The Design:
I have three tables. One is called Residential. The Second is Business. The third is Requests. Residential and Business Both contain a primary key that is called cust_id.

The Problem:
When create the requests table I issue the following command
Code:
CREATE TABLE requests ( request_id int not null auto_increment Primary Key, cust_id int not null references residential(cust_id) and references business(cust_id), blah blah blah.... ) ENGINE = InnoDB;
I get a syntax error right around the "and references". I have it so the residential customers will all be odd and the business customers will have even id's.

Is it posible for my foreign key to refer back to two tables or am I going to have to combine the two tables into one?
jstephens is offline   Fork this post Reply With Quote
Old 02-24-2006, 05:31 PM   #2
Azkaban
Senior Member
 
Join Date: Jul 2004
Posts: 167 Azkaban is on a distinguished road
Re: Foreign Key too Two Tables

I can't really help you because I know nothing of foreign keys, but looking at the documentation for it, I see no reference to the word "AND" in the syntax.
http://dev.mysql.com/doc/refman/5.0/...nstraints.html

Looking in the notes, one person had tried something where it looked like references 'tablename1','t2'(columns) or something like that. He also got an error but he said it was due to referencing an ISAM table.

This probably won't help but I gave it a shot.
__________________
** Most misspellings intentional to combat spaham filterz**
Azkaban is offline   Fork this post Reply With Quote
Old 02-24-2006, 07:11 PM   #3
jstephens
Junior Member
 
Join Date: Feb 2006
Posts: 5 jstephens is on a distinguished road
Re: Foreign Key too Two Tables

Thanks. That was the first place I looked at. Right now I have the two tables broken down into one table but I would like to use it the other way if at all possible.
jstephens is offline   Fork this post Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating MySQL Memory Tables martman General 1 11-24-2004 08:26 AM
1.2.4 How Big MySQL Tables Can Be Administrator Documentation 3 10-21-2004 12:38 AM
3.6 Examples of Common Queries Administrator Documentation 9 06-29-2004 09:07 AM
3.4 Getting Information About Databases and Tables Administrator Documentation 0 06-25-2004 01:27 PM
1.8 MySQL Standards Compliance Administrator Documentation 21 06-08-2004 03:18 AM



All times are GMT -4. The time now is 05:34 AM.



Powered by: vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Google
  Web http://www.mysqltalk.com
DISCLAIMERS:
1. We have no commercial interest in this site.
Banner Ads and Subscriptions will only be used to help pay for hosting and maintenance costs.
2. MySQLTalk.com is NOT affiliated with MySQL AB in any way.
3. MySQLTalk.com is NOT endorsed by MySQL AB in any way.
4. Please do not post any content that is harmful to MySQL or MySQL AB, meaning no misleading or obsolete information will be tolerated.
Well-founded constructive criticism meant to help the community is permitted.
5. This website is founded with the goal of improving the MySQL community.
We not only tolerate newbies, we encourage them.
Please do not ask newbies to "read the manual".