SQL 查找和引用表定义

发布于 2024-12-26 16:37:10 字数 273 浏览 2 评论 0原文

我需要一些澄清。 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

柠檬色的秋千 2025-01-02 16:37:10

表 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.

无声无音无过去 2025-01-02 16:37:10

这些术语没有硬性定义。这实际上取决于对方是否知道你在说什么。

在我工作的人中,表 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".

盗心人 2025-01-02 16:37:10
  • 分叉表
  • 多对多关系表
  • 链接表
  • 映射表
  • Fork table
  • many-to-many relation table
  • link table
  • map table
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文