Click here to Skip to main content
14,303,493 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
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.....
VJ Reddy 4-May-12 20:48pm
   
You're welcome and thank you for the response.
If the solution is helpful then you may accept using the accept button provided in the title of solution and vote the solution.

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100