When having an identity column is not a good idea?

后端 未结 8 492
深忆病人
深忆病人 2021-01-12 04:06

In tables where you need only 1 column as the key, and values in that column can be integers, when you shouldn\'t use an identity field?

To the contrary, in

8条回答
  •  粉色の甜心
    2021-01-12 04:45

    I recently implemented a Suffix Trie in C# that could index novels, and then allow searches to be done extremely fast, linear to the size of the search string. Part of the requirements (this was a homework assignment) was to use offline storage, so I used MS SQL, and needed a structure to represent a Node in a table.

    I ended up with the following structure : NodeID Character ParentID, etc, where the NodeID was a primary key.

    I didn't want this to be done as an autoincrementing identity for two main reasons.

    1. How do I get the value of a NodeID after I add it to the database/data table?
    2. I wanted more control when it came to generating my own IDs.

提交回复
热议问题