At that time I was a bit nervous, whether to use INT data type as the primary key or to use GUID type as the primary key; so I started working on that and took a chance to speak to my other team members and do some kind of a research on it. after having a proper understanding on that I used INT as my primary key based on the details I found on technical articles.
Below are the main advantages and disadvantages about both INT and GUID data type.
Advantages
INT
- Small amount of storage size (and integer is 4 bytes)
- Increased readability, practical use in testing, and easy to understand
- Support for functions that return the last primary key generated (@@IDENTITY, SCOPE_IDENTITY())
GUID
- The primary key is uniquely identified in the entire system (Unique across the server.)
- Easy to merge tables
- Don't have problems when inserting a large number of operations
Disadvantages
INT
- Hard to work with distributed tables
- Primary key in the form of INT/BIGINT is LUID, local unique identifier, which is only used locally in a table
- After a large number of operations (insert, delete), the counter for primary key can be reset, bringing the problem of chronology to 1
GUID
- Bigger storage size (16 bytes - four times the size of an integer)
- Hard to remember and understand
No comments:
Post a Comment