Different types of SQL keys and their usage

Asked By 20 points N/A Posted on -
qa-featured

What is a primary key? What is a secondary key? What is a foreign key? What is the difference between each of them? Where are they used? What is a join? What are the different kinds of joins? Explain how they work? Can you differentiate between GROUP BY and ORDER BY?

SHARE
Answered By 0 points N/A #152199

Different types of SQL keys and their usage

qa-featured
A key is generally a single or combination of multiple fields 
in a database table. Their main use is to retrieve the 
required data from the table.The main types are-
1.Candidate key- A candidate is a combination of various columns
in a table. A number of candidate keys are allowed in a table.
2. Super key- A super key is a combination of various keys.
3. Primary key- It's used to distinguish between various columns
of a database table. A single key can be used a primary key.Null
values and duplication are not allowed in a primary key.
 
4. Alternate key -An alternate works as a primary key. It's a
candidate key but not a primary key.
5. Composite key- A combination of primary key and candidate key is 
termed as a composite key.
6. Unique key- It is a primary key which accepts only one NULL
value.
7. Foreign key- It is a primary key which contains NULL and 
duplicate values.
Hope it helps you. 

Related Questions