我如何处理将记录链接到另一个 table?
How do I handle linking a record to another table?
我是 Access 的新手,我的老师……很难跟上。所以我觉得这里可能缺少一些非常基本的东西。我认为我在这个问题上遇到的最大问题是我正在努力寻找词语来传达我实际需要做的事情,这真的让我的 google-fu 感到沮丧。
就我想的我想做的,我想做一个完整的参考另一个table的记录。
Main
+----+-------+--------+-------+----------------------------+
| PK | Name | Phone# | [...] | Cards |
+----+-------+--------+-------+----------------------------+
| 1 | Bob | [...] | [...] | < Reference to 2nd table > |
| 2 | Harry | [...] | [...] | [...] |
| 3 | Ted | [...] | [...] | [...] |
+----+-------+--------+-------+----------------------------+
Bob's Cards
+----+-------------+-----------+-------+-------+-------+
| PK | Card Name | Condition | Year | Price | [...] |
+----+-------------+-----------+-------+-------+-------+
| 1 | Big Slugger | Mint | 1987 | .20 | [...] |
| 2 | Quick Pete | [...] | [...] | [...] | [...] |
| 3 | Mac Donald | [...] | [...] | [...] | [...] |
+----+-------------+-----------+-------+-------+-------+
如果可能的话,主 table 中的每条记录都需要一个全新的 table。
但我能想到的唯一替代解决方案是将 'Card1, Condition1, [...], Card2, Condition2, [...], Card3, [...]' 字段添加到主 table 并且在有人增加存储的最大卡片数量时必须添加另一组字段。
所以我有点相信我应该采取其他一些方法,但我们的老师未能正确解释。我们甚至还没有触及表格和报告,所以我不需要担心如何处理它们。
有什么指点吗?
(另外,整个数据和结构只是我自己的粗略复制品,因为我宁愿学习如何做并自己应用它,也不愿像“这是我的数据,请修复”。 )
第三个选项在乐于助人的 Minty 的评论中成功找到。
This depends on a number of things, however to keep it simple you
would normally add one field to the cards table, with an number data
type called CardOwnerID. In your example it would be 1 indicating Bob.
This is known as a foreign key. (FK) - However if you have a table of
cards and multiple possible owners then you need a third table - a
Junction table. This would consist of the Main Person ID and the Card
ID. – Minty
我是 Access 的新手,我的老师……很难跟上。所以我觉得这里可能缺少一些非常基本的东西。我认为我在这个问题上遇到的最大问题是我正在努力寻找词语来传达我实际需要做的事情,这真的让我的 google-fu 感到沮丧。
就我想的我想做的,我想做一个完整的参考另一个table的记录。
Main
+----+-------+--------+-------+----------------------------+
| PK | Name | Phone# | [...] | Cards |
+----+-------+--------+-------+----------------------------+
| 1 | Bob | [...] | [...] | < Reference to 2nd table > |
| 2 | Harry | [...] | [...] | [...] |
| 3 | Ted | [...] | [...] | [...] |
+----+-------+--------+-------+----------------------------+
Bob's Cards
+----+-------------+-----------+-------+-------+-------+
| PK | Card Name | Condition | Year | Price | [...] |
+----+-------------+-----------+-------+-------+-------+
| 1 | Big Slugger | Mint | 1987 | .20 | [...] |
| 2 | Quick Pete | [...] | [...] | [...] | [...] |
| 3 | Mac Donald | [...] | [...] | [...] | [...] |
+----+-------------+-----------+-------+-------+-------+
如果可能的话,主 table 中的每条记录都需要一个全新的 table。
但我能想到的唯一替代解决方案是将 'Card1, Condition1, [...], Card2, Condition2, [...], Card3, [...]' 字段添加到主 table 并且在有人增加存储的最大卡片数量时必须添加另一组字段。
所以我有点相信我应该采取其他一些方法,但我们的老师未能正确解释。我们甚至还没有触及表格和报告,所以我不需要担心如何处理它们。
有什么指点吗?
(另外,整个数据和结构只是我自己的粗略复制品,因为我宁愿学习如何做并自己应用它,也不愿像“这是我的数据,请修复”。 )
第三个选项在乐于助人的 Minty 的评论中成功找到。
This depends on a number of things, however to keep it simple you would normally add one field to the cards table, with an number data type called CardOwnerID. In your example it would be 1 indicating Bob. This is known as a foreign key. (FK) - However if you have a table of cards and multiple possible owners then you need a third table - a Junction table. This would consist of the Main Person ID and the Card ID. – Minty