多个多对多关系(循环关系) [英] Multiple Many-to-Many Relationships (Circular Relationship)

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

问题描述

好吧,我是编程人员的新手,主要是通过阅读站点来学习自己的知识....但是我正在寻找一个我在任何地方都找不到完整解释的答案.

OK, I'm new to programming things, mainly learned myself by reading sites.... but I'm looking for an answer I haven't found fully explained anywhere.

我在数据库中有三个表: - 部分 - 工具 -机器

I have three tables in a database: - Parts - Tools - Machines

我已经阅读了许多连接这三个表的两个联结表的实例,但这可以是循环的,并且我有三个联结表将三个信息表连接起来吗?

I have read many instances of two junction tables connecting these three tables, but can this be circular, and I have three junction tables connecting the three info tables?

这些都是多对多关系....例如:

These are all Many-to-Many relationships.... for example:

A部分和B部分均由工具1制成 A部分也由工具2制成 工具1可以安装在机器X,Y和Z中 A部分只能进入机器X和Z B部分只能进入X和Y机器

Part A and B are both made from Tool 1 Part A is also made from Tool 2 Tool 1 can fit in Machine X and Y and Z Part A can only go in Machine X and Z Part B can only go in machine X and Y

联结表的这种圆形"引用有效吗?

Does this "circular" reference of junction tables work?

我在想我需要一个: 零件到工具JCT 工具对机器JCT 机器对零件JCT

I'm thinking I need to have a: Part-to-Tool JCT Tool-to-Machine JCT Machine-to Part JCT

这是一个很好的圆形关系链接...我想我还没有找到任何在线显示此示例的示例.

This makes a nice round relationship link... and I guess I haven't found any examples showing this online anywhere.

任何帮助将不胜感激!

推荐答案

您需要设置如下表:

tblPart-零件A和B的记录

tblPart - records for parts A and B

tblTool-工具1和2的记录

tblTool - records for tools 1 and 2

tblMachine-机器X,Y和Z的记录

tblMachine - records for machines X, Y and Z

tblToolPart(字段:ToolId,PartId)-记录1,A; 1,B; 2,A.

tblToolPart (fields: ToolId, PartId) - records 1, A; 1, B; 2, A.

tblPartMachine(字段:PartId,MachineId)-记录A,X; A,Z; B,X; B,Y.

tblPartMachine (fields: PartId, MachineId) - records A, X; A, Z; B, X; B,Y.

tblMachineTool(字段:MachineId,PartId)-记录X,1; Y,1; Z,1.

tblMachineTool (fields: MachineId, PartId) - records X, 1; Y, 1; Z, 1.

不知道这是否足够清楚,无法理解这个主意,但是有了这6个表,您就可以开始构建查询以导入您感兴趣的任何关系.

Don't know if this is clear enough to get the idea over, but with these 6 tables you can begin building queries to import whatever relationships you're interested in.

这篇关于多个多对多关系(循环关系)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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