Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
sir
I'have created 5 tables :
1) Contact
2) Groups

3) friends
4) Specials
5) Families
I want to relate table contact with other 3 tables :1) friends
2) specials
3) families.
Is this possible to relate one table to multiple tables?
Posted

1 solution

Yes, it is possible to relate one table to multiple tables.

There are basically three types of relations One to Many, Many to Many and One to One as explained here http://msdn.microsoft.com/en-us/library/ms190651(v=sql.90).aspx[^]

From the name of the table Contact it appears that this table is to store the contact information of persons. So, there can be one row or record for each person, and the PrimaryKey to uniquely identify each record is say ContactId. Then to establish a relationship between this table and other tables, create a ForeignKey say ContactId in each of the tables friends, specials, families.

Now create one of the three relationships mentioned above between table Contact and each of the others tables, according to requirement. In this case there can be One to Many if more than one contact is expected in the second table (i.e. friends, specials or families) or One to One if only one contact is expected in the other table (friends, specials or families) . A detailed tutorial on how to create a relation ship is given here
http://www.functionx.com/sqlserver2005/Lesson13.htm[^]

I think it may be helpful.
 
Share this answer
 
Comments
Sandeep Mewara 29-Apr-12 1:47am    
5'ed!
tusharkaushik 29-Apr-12 4:20am    
but how can i do it ! I cant understood!
VJ Reddy 29-Apr-12 11:09am    
Please read the second reference in the above answer, where it is lucidly explained how to assign relationships. Then do the example as explained in the above article.
VJ Reddy 29-Apr-12 11:06am    
Thank you, Sandeep.
tusharkaushik 4-May-12 13:14pm    
Very-Very thanks for ur co-operations.....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900