Keys :- A Key is a data item that exclusively identifies a record. In other words, key is a set of column(s) that is used to uniquely identify the record in a table. It is used to fetch or retrieve records / data-rows from data table according to the condition/requirement. Key provide several types of constraints like column can’t store duplicate values or null values. Keys are also used to generate relationship among different database tables or views.
Types of Keys :
- Primary Key –
Dimension table’s every row is identified by a unique value which is generally known as primary key of the table. Extraordinary type of one of a kind limitation which can be utilized as the essential method to recover an interesting record from the table. Tables can have numerous interesting records, however it can have just a single Primary Key Constraint. This requirement is actualized by means of a one of a kind file and is accessible to be referenced by a Foreign Key.
- Super Key – Super key is a set of on e or more than one keys that can be used to uniquely identify the record in table. A Super key for an entity is a set of one or more attributes whose combined value uniquely identifies the entity in the entity set. A super key is a combine form of Primary Key, Alternate key and Unique key and Primary Key, Unique Key and Alternate Key are subset of super key. A Super Key is simply a non-minimal Candidate Key, that is to say one with additional columns not strictly required to ensure uniqueness of the row. A super key can have a single column.
- Foreign Key –
In the fact table the primary key of other dimension table is act as the foreign key.
- Alternate key –
It is also a unique value of the table and generally knows as secondary key of the table.
- Composite key –
It is the key which consist of two or more attribute.
For example, the entity has a clientID and a employeeCode as its primary key. Every one of the characteristics that make up the primary key are basic keys on the grounds that each speaks to an exceptional reference while distinguishing a client in one occasion and a employee in the other, so this key is a composite key.
- Candidate key –
A substance type in an intelligent information model will have at least zero competitor keys, likewise alluded to just as one of a kind identifiers . For instance, on the off chance that we just interface with American residents, at that point SSN is one up-and-comer key for the Person element type and the mix of name and telephone number (expecting the mix is one of a kind) is possibly a subsequent competitor key. Both of these keys are called up-and-comer keys since they are possibility to be picked as the essential key, a substitute key or maybe not so much as a key at all inside a physical information model.