P2Pprogrammer 2 programmer

Home > Interview Question and Answer > Database General

Database General Interview Question and Answer


Interview questions and Answers for Database General, Concept, Normalization, Joins, Views, Index, Triggers

IT Interview questions and answers for Database general concept, interview question answers for database design concept including normalization. Interview question answers for database objects tables, views, indexes, triggers, stored procedure. Interview questions and answers for database relationship, constraints, joins.

This interview questions and answers are not related to any specific database type like oracle, MS SqlServer, MySQL. This interview questions and answers to judge knowledge of database concept , design concept and database administrator (DBA)



Database General, Concept Interview Question and Answer


1. What is normalization

Well a relational database is basically composed of tables that contain related data. So the Process of organizing this data into tables is actually referred to as normalization.

2. What is a Stored Procedure

Its nothing but a set of SQL statements combined to perform a single task of several tasks. Its basically like a Macro so when you invoke the Stored procedure, you actually run a set of statements.

3. Can you give an example of Stored Procedure ?

sp_helpdb , sp_who2, sp_renamedb are a set of system defined stored procedures. We can also have user defined stored procedures which can be called in similar way.

4. What is a trigger?

Triggers are basically used to implement business rules. Triggers is also similar to stored procedures. The difference is that it can be activated when data is added or edited or deleted from a table in a database.

5. What is a view?

If we have several tables in a db and we want to view only specific columns from specific tables we can go for views. It would also suffice the needs of security some times allowing specfic users to see only specific columns based on the permission that we can configure on the view. Views also reduce the effort that is required for writing queries to access specific columns every time.

6. What is an Index?

When queries are run against a db, an index on that db basically helps in the way the data is sorted to process the query for faster and data retrievals are much faster when we have an index.

7. What is the basic difference between clustered and a non-clustered index?

The difference is that, Clustered index is unique for any given table and we can have only one clustered index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index. Whereas in case of non-clustered index the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db.

8. What are cursors?

Well cursors help us to do an operation on a set of data that we retreive by commands such as Select columns from table. For example : If we have duplicate records in a table we can remove it by declaring a cursor which would check the records during retreival one by one and remove rows which have duplicate values.

9. Can you tell the difference between DELETE & TRUNCATE commands?

Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.

10. Can we use Truncate command on a table which is referenced by FOREIGN KEY?

10. Can we use Truncate command on a table which is referenced by FOREIGN KEY?

11. What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?

Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.

12. What do you mean by COLLATION?

Collation is basically the sort order. There are three types of sort order Dictionary case sensitive, Dictonary - case insensitive and Binary.

13. What are Joins ?

Join actually puts data from two or more tables into a single result set.

14. Can you explain the types of Joins that we can have with Sql Server?

There are three types of joins: Inner Join, Outer Join, Cross Join

15. What is difference between UNIQUE and PRIMARY KEY constraints?

Both are Constraints and both creates an index on the specified columns.
UNIQUE is a constraint which enforces distinct column values on a table column and can contain a NULL record also.
PRIMARY KEY is a constraint similar to UNIQUE, however it cannot have a Null value for the column. Moreover a PRIMARY KEY can be the parent column for a Parent - Child relationship(Foreign Key).

16. What is a OUTER JOIN?

An OUTER JOIN returns all rows that satisfy the join condition and also returns some or all of those rows from one table for which no rows from the other satisfy the join condition.

17. When do you use WHERE clause and when do you use HAVING clause?

The WHERE condition lets you restrict the rows selected to those that satisfy one or more conditions. Use the HAVING clause to restrict the groups of returned rows to those groups for which the specified condition is TRUE.

18. What is difference between Rename and Alias?

Rename is actually changing the name of an object whereas Alias is giving another name (additional name) to an existing object

19. What are various joins used while writing SUBQUERIES?

IN, NOT IN, IN ANY, IN ALL, EXISTS, NOT EXISTS.

20. How you will avoid your query from using indexes?

By changing the order of the columns that are used in the index, in the Where condition, or by concatenating the columns with some constant values.



Home > Interview Question and Answer > Database General