Friday, December 22, 2006

SQL Server interview questions - Part I

I am not much stronger in SQL Server. Still, I browse for something and found the following questions for my friend. Willing to post the same to you as well:

1) What is a Stored Procedure?

Ans: Its 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.


2) What is normalization?

Ans: In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables.

There are three main normal forms, each with increasing levels of normalization:

First Normal Form (1NF): Each field in a table contains different information. For example, in an employee list, each table would contain only one birthdate field.

Second Normal Form (2NF): Each field in a table that is not a determiner of the contents of another field must itself be a function of the other fields in the table.

Third Normal Form (3NF): No duplicate information is permitted. So, for example, if two tables both require a birthdate field, the birthdate information would be separated into a separate table, and the two other tables would then access the birthdate information via an index field in the birthdate table. Any change to a birthdate would automatically be reflect in all tables that link to the birthdate table.

There are additional normalization levels, such as Boyce Codd Normal Form (BCNF), fourth normal form (4NF) and fifth normal form (5NF). While normalization makes databases more efficient to maintain, they can also make them more complex because data is separated into so many different tables.


3) What is a trigger?

Ans: 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.


4) What is a view?

Ans: 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.


5) What is the usage of Cursors in SQL?

Ans: 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.


These are the basic theory based questions that may ask for the candidates. Still, there are some other important questions specific to MS SQL Server which may appear for them. I will try to cover it in following sessions.

You can also check for more SQL Server questions from blogs of Mr. Vadivel.

C u soon...

happy coding....

:))

2 comments:

  1. Your blog is a good comprehensive non-tech and tech resources. You can also start using tag labels for better categorizations/search.

    ReplyDelete
  2. Sure Deepak. I will do tag labels in my future blogs. Thanks for your idea...

    ReplyDelete