Seek Interview Questions: 8/15/10 - 8/22/10

Wednesday, August 18, 2010

What is the use of DBCC commands

DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e., maintenance, validation task and status checks.
E.g. DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.
DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.

What is cursors

Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time.In order to work with a cursor we need to perform some steps in the
following order:

  • Declare cursor
  • Open cursor
  • Fetch row from the cursor
  • Process fetched row
  • Close cursor
  • Deallocate cursor

What are the different index configurations a table can have

A table can have one of the following index configurations:
  • No indexes
  • A clustered index
  • A clustered index and many nonclustered indexes 
  • A nonclustered index 
  • Many nonclustered indexes

What is the difference between clustered and a non-clustered index

A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.

A nonclustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a nonclustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

What is Index

An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes, they are just used to speed up queries. Effective indexes are one of the best ways to improve performance in a database application. A table scan happens when there is no index available to help a query. In a table scan SQL Server examines every row in the table to satisfy the query results. Table scans are sometimes unavoidable, but on large tables, scans have a terrific impact on performance.

Clustered indexes define the physical sorting of a database table’s rows in the storage media. For this reason, each database table may have only one clustered index. Non-clustered indexes are created outside of the database table and contain a sorted list of references to the table itself.

What is View

A simple view can be thought of as a subset of a table. It can be used for retrieving data, as well as updating or deleting rows. Rows updated or deleted in the view are updated or deleted in the table the view was created with. It should also be noted that as data in the original table changes, so does data in the view, as views are the way to look at part of the original table. The results of using a view are not permanently stored in the database. The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.

What is Trigger

A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs. Triggers are stored in and managed by the DBMS.Triggers are used to maintain the referentialintegrity of data by changing the data in a systematic fashion. A trigger cannot be called or executed; the DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers can be viewed as similar to stored procedures in that both consist of procedural logic that is stored at the database level. Stored procedures, however, are not event-drive and are not attached to a specific table as triggers are. Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed. In addition, triggers can also execute stored procedures.

Nested Trigger: A trigger can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger.

What is Stored Procedure

A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database. e.g. sp_helpdb, sp_renamedb, sp_depends etc.

What are different normalization forms

1NF: Eliminate Repeating Groups
Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.

2NF: Eliminate Redundant Data
If an attribute depends on only part of a multi-valued key, remove it to a separate table.

3NF: Eliminate Columns Not Dependent On Key
If attributes do not contribute to a description of the key, remove them to a separate table. All attributes must be directly dependent on the primary key BCNF: Boyce-Codd Normal Form If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.

4NF: Isolate Independent Multiple Relationships
No table may contain two or more 1:n or n:m relationships that are not directly related.

5NF: Isolate Semantically Related Multiple Relationships
There may be practical constrains on information that justify separating logically related many-to-many relationships.

ONF: Optimal Normal Form
A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.

DKNF: Domain-Key Normal Form
A model free from all modification anomalies.
Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF database.

What is normalization

Database normalization is a data design and organization process applied to data structures based on rules that help build relational databases. 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. The objective is to isolate data so that additions, deletions,and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships. Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.

What is RDBMS

Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.

Tuesday, August 17, 2010

What is Meta Data Repository

Meta Data is a data about the data.It also contains

Query statistics

ETL statistics

Business subject area

Source Information

Target Information

Source to Target mapping Information.

What is Data Stage Engine

It is a JAVA engine running at the background.

Construct pipes to execute the following jobs

  1. Output of who should be displayed on the screen with value of total number of users who have logged indisplayed at the bottom of the list.
  2. Output of ls should be displayed on the screen and from this output the lines containing the word ‘poem’should be counted and the count should be stored in a file.
  3. Contents of file1 and file2 should be displayed on the screen and this output should be appended in a file.From output of ls the lines containing ‘poem’ should be displayed on the screen along with the count.
  4. Name of cities should be accepted from the keyboard . This list should be combined with the list presentin a file. This combined list should be sorted and the sorted listshould be stored in a file ‘newcity’.
  5. All files present in a directory dir1 should be deleted any error while deleting should be stored in a file‘errorlog’.

UNIX Commands Interview Questions

  • Construct pipes to execute the following jobs.
  • Explain the following commands.
  • What is the significance of the “tee” command?
  • What does the command “ $who | sort –logfile > newfile” do?
  • What does the command “$ls | wc –l > file1” do?
  • Which of the following commands is not a filter man , (b) cat , (c) pg , (d) head
  • How is the command “$cat file2 “ different from “$cat >file2 and >> redirection operators ?

What is Star Schema

Star Schema is a de-normalized multi-dimensional model. It contains centralized fact tables surrounded by dimensions table.

Dimension Table: It contains a primary key and description about the fact table.

Fact Table: It contains foreign keys to the dimension tables, measures and aggregates.

What is Dimensional Modeling

Dimensional Modeling is a logical design technique that seeks to present the data

in a standard framework that is, intuitive and allows for high performance access.

What is Data Stage Engine

It is a JAVA engine running at the background.

What is Meta Data Repository

Meta Data is a data about the data.It also contains

  • Query statistics
  • ETL statistics
  • Business subject area
  • Source Information
  • Target Information
  • Source to Target mapping Information.

Setting the Polling Interval in SQL server

The service status of various SQL Server components is monitored regularly by SQL Server Enterprise Manager and SQL Server Service Manager. Both allow the monitoring interval to be changed.

Using SQLServerAgent Service

SQLServerAgent is a Windows NT 4.0 or Windows 2000 service that executes jobs, monitors SQL Server, and fires alerts. SQLServerAgent is the service that allows you to automate some administrative tasks. As such, you must start the SQLServerAgent service before your local or multiserver administrative tasks can run automatically. SQL Server Agent runs as a service called SQLServerAgent if it is the default instance or SQLAgent$instancename if it is a named instance.If the SQL Server service and SQL Server Agent service are not configured to start automatically, you must start them manually.

Using SQL Server Service Manager

If you are running Microsoft Windows 98, SQL Server Service Manager can be used start, pause, stop and check the state of local services, though it cannot remotely administer services.

If you have to restart your computer, SQL Server Service Manager appears automatically and the default service is displayed. It is possible to change the default service on the local computer through the SQL Server Service Manager. When you restart the computer, the default service will now be displayed in SQL Server Service Manager. For example, if you change the default service to SQL Server Agent service, and then shut down the computer, the next time you start it, SQL Server Agent service will be displayed in SQL Server Service Manager.

SQL Server Service Manager can also be used to start, pause, or stop an instance of SQL Server 2000 Analysis Services.



To change the default service Service Manager

How to change the default service (Service Manager)

To change the default service

Right-click SQL Server Service Manager, and then click Options.

In the Default Service box, select the new default service to view through SQL Server Service Manager. When you restart the computer, the service that appears is the new default. For example, if you change the default service to SQLServerAgent service and then shut down the computer, the next time you start it, SQLServerAgent service will be displayed in Service Control Manager. You can only change the default service for the local machine.

Using the SQL Server Service

Ans). When you start an instance of SQL Server, you are starting the SQL Server service. After you start the SQL Server service, users can establish new connections to the server. The SQL Server service can be started and stopped as a Microsoft Windows NT® 4.0 or Windows® 2000 service, either locally or remotely. The SQL Server service is referred to as MSSQLServer if it is the default instance, or MSSQL$instancename if it is a named instance.

Starting, Pausing, and Stopping SQL Server

Starting, Pausing, and Stopping SQL Server
Ans). Before you log in to an instance of Microsoft® SQL Server™, you need to know how to start, pause, and stop an instance of SQL Server. After you are logged in, you can perform tasks such as administering the server or querying a database.

Monday, August 16, 2010