Anonymous

What Is A Key? Describe Different Types Of Keys Used In Database?

3

3 Answers

saima jabeen Profile
saima jabeen answered
Key
A key is a single or combination of multiple fields. Its purpose is to access or retrieve data rows from table according to the requirement. The keys are defined in tables to access or sequence the stored data quickly and smoothly. They are also used to create links between different tables.

Types of Keys
The following tables or relations will be used to define different types of keys.

Primary Key
The attribute or combination of attributes that uniquely identifies a row or record in a relation is known as primary key.

Secondary key
A field or combination of fields that is basis for retrieval is known as secondary key. Secondary key is a non-unique field. One secondary key value may refer to many records.

Candidate Key or Alternate key
A relation can have only one primary key. It may contain many fields or combination of fields that can be used as primary key. One field or combination of fields is used as primary key. The fields or combination of fields that are not used as primary key are known as candidate key or alternate key.
Composite key or concatenate key
A primary key that consists of two or more attributes is known as composite key.

Sort Or control key
A field or combination of fields that is used to physically sequence the stored data called sort key. It is also known s control key.

Foreign Key
A foreign key is an attribute or combination of attribute in a relation whose value match a primary key in another relation. The table in which foreign key is created is called as dependent table. The table to which foreign key is refers is known as parent table.
Anonymous Profile
Anonymous answered
Key is a single or combination of multiple field

Types of keys
Primary key
Secondary key
Candidate key
Composite key
Foreign  key
Numan Khan Profile
Numan Khan answered
The term key used in database has vital importance. It is the one of the unique record in Database with the help of which we can identify the other records, let have an example to understand.

Suppose we are making database for school in which every class should have record. Now to identify one student from another student they are assign the roll number or unique number and every student has different roll number from another student, here roll number is acting like a key, if we transform this information into the database than roll number would be primary key (a type of key) in student table.

Basically there are six type of keys in database, but mostly frequently that are used Primary key and foreign key, I hope the concept of primary key would be clear to you, let understand foreign key, a primary key of a table which is used in another table is known as foreign key, for example let us take again the example of school, in school if want to keep the record of courses with students than in course table we will use roll number as foreign key in course table, keep in mind roll number is primary key in student table, in this way we make a relation between student table and course table, that is why it is known as Relational Database.

Answer Question

Anonymous