将一个表与多个表关联 [英] relate one table to multiple tables

查看:84
本文介绍了将一个表与多个表关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生
我已经创建了5个表:
1)联系
2)小组

3)朋友
4)特价
5)家庭
我想将表格联系方式与其他3个表格联系起来:1)朋友
2)特价
3)家庭.

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?

推荐答案

是的,可以将一个表与多个表关联.

基本上有三种类型的关系One to Many, Many to Many and One to One,如此处 http://msdn.microsoft.com/en-us/library/ms190651(v=sql.90).aspx [ http://www.functionx.com/sqlserver2005/Lesson13.htm [
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.


这篇关于将一个表与多个表关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆