/    /  SQL- Interview questions Part 4

1. What are all the different types of indexes?

Answer: There are three types of indexes -.

1. Unique Index.

Unique indexing does not allow the field to have duplicate values if the column is unique indexed. This indexing can be applied automatically when primary key is defined.

2. Clustered Index.

Clustered indexing records the physical order of the table and search based on the key values. Each table can have only one clustered index.

3. NonClustered Index.

This Indexing does not alter the physical order of the table and maintains logical order of data. Each table can have 999 nonclustered indexes.


2. What is a Cursor?

Answer: A database Cursor is a control which enables traversal over the rows or records in the table. This can be viewed as a pointer to one row in a set of rows. It is very much useful for traversing such as retrieval, addition and removal of database records.


3. What is a relationship and what are they?

Answer: Database Relationship is defined as the connection between the tables in a database. There are many data base relationships, and they are as follows:.

1. One to One Relationship.

2. One to Many Relationship.

3. Many to One Relationship.

4. Self-Referencing Relationship.


4. What is a query?

Answer: A DB query is a code written in order to get the information back from the database. It can be designed in such a way that it matched with our expectation of the result set. Simply, a question to the Database.


5. What is subquery?

Answer: A subquery is a query within another query. Outer query is called as main query whereas, inner query is called subquery. SubQuery is executed first, and the result of subquery is passed on to the main query.