SQL 查找和引用表定义
我需要一些澄清。 SQL 中什么是查找表、什么是引用表?
我的印象是,查找表是一张具有几乎不会更改的静态数据的表(例如,一张包含所有 50 个州及其首府的表),而参考表是包含主键并链接其他两个表的表。在下面的示例中,表 B 将是参考表。谁能告诉我B表叫什么?
Table A
CustomerID
CustomerName
CustomerAddress
Table B
CustomerID
OrderID
Table C
OrderID
OrderDate
I need some clarification. What is a lookup table and what is a reference table in SQL?
I was under the impression that a lookup table is a table that has static data that hardly ever changes (e.g. a table that has all 50 states and their capitals) and a reference table is one that contains primary keys and links two other tables. In the example below, Table B would be a reference table. Can someone tell me what Table B is called?
Table A
CustomerID
CustomerName
CustomerAddress
Table B
CustomerID
OrderID
Table C
OrderID
OrderDate
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
表 B 是链接表或连接表。
参考表和查找表对于不同的来源可能意味着不同的东西,我不知道区分两者的严格定义。
就我个人而言,我通常使用引用来表示存储在主表之外的长值(例如
StoreID
),并使用查找来表示某个字段的允许值列表(由 FK 约束强制执行)。Table B is a Link Table or Junction Table.
Reference and Lookup tables can mean different things for different sources, and I am not aware of a strict definition to differentiate the two.
For me personally I normally use a reference to mean an long value stored out of the main table (like a
StoreID
), and lookup to mean a list of allowable values (enforced by a FK constraint) for a certain field.这些术语没有硬性定义。这实际上取决于对方是否知道你在说什么。
在我工作的人中,表 B 被称为“映射表”。
There is no hard-and-fast definition for those terms. It really comes down to whether or not the other person knows what you are talking about.
Among the people I work with table B would be called a "Mapping Table".