4

我关心的是我目前所说的“字典表”,它是包含受控词汇列表的数据库表。

让我们举个例子:假设你有一个表User包含字段:

  • user_id : 主键
  • user_type_id : UserType 表的外键

另一个表UserType 只有两个字段:

  • user_type_id : 主键
  • name :特定类型用户的名称/值。

例如,UserType表可能包含 (1, Administrator), (2, PowerUser), (3, Normal)...

我的问题是:像UserType这样的表的规范术语是什么,它只包含(dictinct)单词的列表。我想发布一些代码来帮助管理这种表,但首先我必须给它们命名!

谢谢你的帮助。

目前的想法: 现在我觉得Lookup Tables 是一个很好的术语。它在这些帖子中也具有相同的含义:

唯一的问题是查找表有时也用于命名联结表。

4

5 回答 5

1

In my experience with SQL developers, the stronger their background in relational theory, the less likely they are to use terms like "lookup table", "validation table", or "dictionary table".

Instead, they just call them tables. Why?

For you, the important part seems to be tables that

  • contain only one text column, or
  • contain only one text column and an id number, or
  • contain only one text column and a short text code, and
  • the primary key is used as the target for foreign key references.

If you think about it for a while, the only thing that distinguishes these tables from others is the number of columns. Relational theory distinguish relations by the number of columns, and I don't feel the need for distinctions like that in SQL, either.

  • Every candidate key implements a controlled vocabulary in this sense--the key (and all the other applicable constraints) provide the mechanism that controls the "vocabulary".
  • Every candidate key can be used as the target for a foreign key reference, regardless of how many candidate keys a table has, regardless of how many columns a candidate key has, and regardless of whether any of the candidate keys are used as foreign key references today.
  • Many such tables only start their life as "lookup" tables. A year down the road, someone discovers the need to store more information. After you add one or two more columns, is it still a "lookup" table, or not?
于 2012-09-03T18:09:52.827 回答
1

我经常将该单词列表视为函数的域(允许的输入值集),因此我将它们称为域表。但这是从数学的角度来看的。

编辑

看:

于 2012-09-03T15:41:57.540 回答
0

您所描述的通常称为数据字典

于 2012-09-03T15:56:39.960 回答
0

你可以走完全相反的方向,用他们的技术名称而不是他们的含义来称呼他们,然后让人们推断——你可以叫他们candidate keys——这在“选择你选择的候选人”的方式中是有道理的;每个候选人都是独一无二的*(或应该是)。

当命名问题不是完全令人头疼的时候,它们往往很有趣:-)

于 2012-09-03T15:57:07.753 回答
0

作为一个 C 编码器,我会说这个表看起来真的很像一个enum(或枚举)。它详尽地定义了可接受的值并将自动给定的整数链接到名称(反之亦然)。

作为一个 SO 用户,我会说这个问题看起来真的有点太开放了,因为我认为没有一个独特的规范名称......

于 2012-09-03T15:47:02.517 回答