Technical Tips, Tricks and Articles

Some Databases

leave a comment »

  • How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?
    Answer:
    • One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships.
    • One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships.
    • Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.

It will be a good idea to read up a database designing fundamentals text book.

  • What’s the difference between a primary key and a unique key?
    Answer:
    Both primary key and unique key enforces uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a non clustered index by default. Another major difference is that, primary key doesn’t allow NULLs, but unique key allows one NULL only.
  • Define candidate key, alternate key, composite key.
    Answer:
    • A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys.
    • A key formed by combining at least two or more columns is called composite key.
  • What is a transaction and what are ACID properties?
    Answer:
    A transaction is a logical unit of work in which, all the steps must be performed or none. ACID stands for Atomicity, Consistency, Isolation, Durability. These are the properties of a transaction.
  • What are defaults? Is there a column to which a default can’t be bound?
    Answer:
    A default is a value that will be used by a column, if no value is supplied to that column while inserting data. IDENTITY columns and timestamp columns can’t have defaults bound to them.
  • What’s the difference between DELETE TABLE and TRUNCATE TABLE commands?
    Answer:
    DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it won’t log the deletion of each row, instead it logs the deallocation of the data pages of the table, which makes it faster. Of course, TRUNCATE TABLE can be rolled back.
  • What is RAID and what are different types of RAID configurations?
    Answer:
    RAID stands for Redundant Array of Inexpensive Disks, used to provide fault tolerance to database servers. There are six RAID levels 0 through 5 offering different levels of performance, fault tolerance. MSDN has some information about RAID levels and for detailed information, check out the RAID advisory board’s homepage.
  • What is blocking and how would you troubleshoot it?
    Answer:
    Blocking happens when one connection from an application holds a lock and a second connection requires a conflicting lock type. This forces the second connection to wait, blocked on the first.
  • What is an extended stored procedure? Can you instantiate a COM object by using T-SQL?
    Answer:
    An extended stored procedure is a function within a DLL (written in a programming language like C, C++ using Open Data Services (ODS) API) that can be called from T-SQL,just the way we call normal stored procedures using the EXEC statement. Yes, you can instantiate.
Advertisements

Written by ..alee

December 13, 2006 at 3:38 pm

Posted in databases, interview, sql

Tagged with , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: