主键与 RRN
主键和 RRN 有什么区别?
What's the difference between a primary key and an RRN?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
主键和 RRN 有什么区别?
What's the difference between a primary key and an RRN?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
主键唯一且明确地标识给定记录(在数据库表/视图中)或给定行(在文本文件中)。虽然主键基于单个字段(单个“列”)可能很方便,但主键也可能基于多个字段/列。
RRN 是一个缩写词,可以理解为“记录行号”或“相对行号”。记录行号通常被理解为一个数字,通常(但不一定)通过简单增量(基于先前分配的 RRN 的值)分配,该增量被“添加”到特定记录类型的其他字段/列。许多 DBMS 提供支持此类“自动递增”或更普遍的自动分配 RRN 的功能。
如上所述,RRN 可以用作主键。
与基于记录的[一个或多个]属性(字段或列)值的主键相比,拥有[语义无效] RRN 有许多优点和缺点。这可能在其他 SO 问题中讨论过;以下是一些最常见的参数:
例如,如果主键是社会安全号码 (SSN),则记录有时可能会更新,因为 SSN 最初输入时存在拼写错误。当/如果发生这种情况,任何使用此 SSN 引用更新记录的相关记录也需要更新。如果这些相关记录使用[非有意义的] RRN,它们将不会受到 SSN 值可能发生的变化的影响。
A Primary key uniquely and unambiguously identifies a given record (in a database table/view) or a given row (in a text file). Although it can be convenient for the primary key to be based on a single Field (a single "column"), it is also possible for a primary to be based on several Fields/Columns.
RRN is an acronym which can either be understood as "Record Row Number" or "Relative Row Number". The Record Row Number is generally understood to be a number, typically (but not necessarily) assigned by simple increment (based on the value of the previous such RRN assigned) which is "added" to the other Fields/Column of a particular record type. Many DBMSes supply features for the support of such "auto-incremented" or more generally automatically assigned RRNs.
Defined as above, an RRN can be used as a Primary Key.
There are many advantages -and drawbacks- to having a [semantically void] RRN as opposed to a Primary key based on [one or several] attribute (Field or Column) values of the record. This is probably discussed in other SO question; here are a few of the most common arguments:
For example if the primary key is a Social Security Number (SSN), a record may at some time be updated because the SSN was originally input with a typo error. When/if that happens, any related records which uses this SSN to refer to the updated record need to also be updated. Had these related records used the [non significative] RRN, they would be immune to possible changes of the SSN value.
主键标识表中的一行。
RRN(我想您指的是相对记录号)还按子集(即查询结果)中的位置来标识行。
我发现如果您需要推断一组与主键不相关的记录的顺序,它很有用。
A Primary key identifies a row in a table.
An RRN (I presume you mean Relative Record number) also identifies a row by position in a subset (ie. a query result).
I've found it useful if you need to extrapolate a sequential order for a set of records not related to the primary key.