![]() In most database systems, this corresponds to the BIGINT type. The key here is that the External Id the user sees only exists in one record, whereas the Internal Id is used throughout the system to connect different records.įor the purpose of this article, we’ll assume key generation is the common approach of assigning long integers to each record in a table. In the case the system does need to expose a key, such as an eBay item number found in the URL of the auction, the system may create two keys: an Internal Id that is used for table relations within a database, and an External Id used to perform lookups on behalf of the user. This is a huge boon to security and prevents users from attacking the system. A third, less followed, requirement is that unique keys should be private and only used internally by the application server. ![]() Changing unique keys is often an extremely difficult, highly risk process. This leads us to our second requirement of unique keys: Unique keys should not change throughout the life of the system. Even if unique natural keys did exist – e-mail for example – what if a user wants to change their address down the road? Also, it’s been reported the government has been known to recycle social security numbers, as well as the fact that people can be issued new social security numbers during their lifetime. As an example, Bob’s social security number might seem like a natural key since it is unique to Bob but it may be the case Bob is a visiting foreigner (or the application is deployed outside the country) in which a US social security number is not applicable. ![]() We could spend time discussing Natural Keys, although I would argue there is no such thing as natural keys. This key is unique for Bob and is a lot easier to pass around a system then Bob’s full name, since there may be other Bob Jones’s in the system. For example, a user “Bob Jones” might have a User Id associated with the record of 808182313713. Most (good) database systems assign a unique key, usually a large number, to every record in the database. This article discusses some of the techniques and limitations offered to Java JDBC programmers. All JDBC programmers at one time or another have had to deal with key generation for new records, or more precisely, how to retrieve keys for newly created records.
0 Comments
Leave a Reply. |