SQL: Keys,Natural Keys, Artificial Keys, Surrogate Keys, Physical Locators

SQL+NoSQL+JOBS
Natural Keys: -A natural key is a subset of attributes that occur in a table and act as a unique identifier. The user sees them. You can go to the external reality and verify them. Example: bar codes on consumer goods (read the package), geographic coordinates (get a GPS), or the VIN on an automobile (read the tag riveted to the dashboard, etched into the windows, and engraved on the engine block).

Artificial Keys:-
An artificial key is an extra attribute added to the table that is seen by the user. It does not exist in the external reality but can be verified for syntax or check digits inside itself. Example: the open codes in the UPC/EAN scheme that a user can assign to his own stuff.

For example, a grocery store not only sells packaged good with preprinted bar codes but also bakes bread in the store and labels them with an open code. The check digits still work, but you have to verify them inside your own enterprise.

Exposed Physical LOactors:
An exposed physical locator is not based on attributes in the data model but on the storage used and is exposed to user. There is no way to predict it or verify it. The system obtains a value through some physical process totally unrelated to the logical data model. The user cannot change them without destroying the relationships among the data elements.

Examples would be physical row locations encoded as a number, string, or even a proprietary data type. If hash values were accessible in an SQL product, then they would qualify, but they are usually hidden from the user.

Surrogate Keys:
Just create a single primary key column for each table and use the system to generate a unique value for each occurrence. For example, we could specify Branch ID as the primary key of Branch and number the first Branch "1," the second "2," and so forth. We refer to all such columns as surrogate keys

Comments

Popular posts from this blog

Top myths for NULL value in SQL Queries