N/APosted on - 11/18/2014
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?
Different types of SQL keys and their usage
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
7. Foreign key- It is a primary key which contains NULL and
Hope it helps you.