MySQL Forums
Forum List  »  InnoDB

foreign key between tables
Posted by: Praveen TS
Date: September 18, 2009 05:05AM

Hi,


I have a scenario, presenting you as follows.

There are 2 tables, and my requirements made me not to define the foreign key relationships.

To be specific

Table1:

create table persons(
id INT PRIMARY KEY,
name varchar
)

Table2:
create table friends(
id Primary key,
persons_id INT FOREIGN KEY REFERENCES persons(id),
friend_email_id VARCHAR
)

If I define the tables as above, I can have foreign key relationships.

but, the problem is if 2 persons have the same friend(ie means same friend_email_id) , I have to store 2 rows.

Instead, if i make persons_id as varchar(or any other), i can store the persons_id seperated by some delimiter.
But foreign key relationships will affect. Then there will be no relation between the tables.

Is there any better approach for this? Any suggestions?.

Options: ReplyQuote


Subject
Views
Written By
Posted
foreign key between tables
4612
September 18, 2009 05:05AM
2440
September 20, 2009 04:42PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.