Professional Documents
Culture Documents
developer applicant
by Tim Chapman | Oct 16, 2006
Tags: Databases, Enterprise software, Tim Chapman, Microsoft SQL Server, database,
foreign key
20 comment(s)
Email
Save
Print
3
Takeaway: Tim Chapman presents his standard set of baseline technical questions he
asks SQL Server database developers during an interview. These questions will help you
weed out less-qualified candidates.
When I interview SQL Server database developer candidates, I use a standard set of
baseline technical questions. The following questions are ones that I find can really help
weed out less-qualified candidates. They are listed in order from easiest to more difficult.
When you get to the question about primary and foreign keys, it starts to get challenging
because the answers can be more difficult to explain and articulate, especially in an
interview setting.
In its most simple terms, an index is a data structure used to provide quick access to data
in a database table or view. In SQL Server, they come in two flavors: clustered and non-
clustered. Clustered indexes store the data at the leaf level of the index. This means that
whichever field(s) in your table are included in the clustered index, they will be stored in
an orderly fashion in the table. Because of this sorting, you can only have one clustered
index per table. Non-clustered indexes contain a row identifier at the leaf level of the
index. This row identifier is a pointer to a location of the data on the disk. This allows
you to have more than one non-clustered index per table.
The value NULL means UNKNOWN; it does not mean '' (empty string). Assuming
ANSI_NULLS are on in your SQL Server database, which they are by default, any
comparison to the value NULL will yield the value NULL. You cannot compare any
value with an UNKNOWN value and logically expect to get an answer. You must use the
IS NULL operator instead.
An AFTER trigger executes after a DML statement has taken place in the database.
These types of triggers are very handy for auditing data changes that have occurred in
your database tables.
The other option is the use of triggers. Triggers can be used to ensure the same effect of
constraints in a roundabout way, but it is much more difficult to set up and maintain, and
the performance is typically worse. Because of this, Microsoft recommends that
developers use foreign key constraints instead of triggers for maintaining referential
integrity.
Triggers can also be used to restrict the values accepted in a field in a database table, but
this solution requires the trigger to be defined on the table, which can hinder performance
in certain situations. For this reason, Microsoft recommends Check constraints over all
other methods for restricting domain integrity.