In the latest installment of the SQL Server interview questions, we will outline questions suitable for a DBA interview to assess the candidates skills related to SQL Server system databases. In this tip, the questions are there to read, but the answers are intentionally hidden to really test your skills. Once you read the question and have determined your answer, then highlight the answer to see how you did. Good luck!
Question Difficulty = Easy
Question 1: What are the SQL Server system databases and can you outline the general functionality of each database?
Master - Database responsible for SQL Server instance related data. You can also think of this database corresponding to the Windows SQL Server service account.
Resource - Database responsible for SQL Server system objects. This database was introduced in SQL Server 2005 and is intended to ease the upgrade and rollback of SQL Server system objects.
Model - Template database for the creation of new user defined databases.
MSDB - Database responsible for SQL Server Agent related data such as Jobs, Alerts, Operators, etc.
TempDB - Temporary database to store temporary tables (#temptable or ##temptale), table variables, cursors, work tables, row versioning, create or rebuild indexes sorted in TempDB, etc. Each time the SQL Server instance is restarted all objects in this database are destroyed, so permanent objects cannot be created in this database.
Distribution - Database responsible for managing replicated data. This database could reside on the publisher or subscriber.
Question 2: True or False - Can you create objects in the Master, Model and MSDB databases?
Question 3: Is it a good idea to create objects in the system databases?
In general , objects should not be created in the system databases. In general, it is a best practice to create a separate database for user defined objects that would be used instance wide or create the objects in each of the needed databases. From a DBA perspective, it is a common practice to create a dedicated DBA database in order to perform custom administrative tasks.
If objects are needed for future user defined databases those can be created in the Model database.
Question 4: Does Reporting Services create system databases during the installation process?
Yes. The databases are:
ReportServer - Stores the reports related data.
ReportServerTempDB - Temporary database storage for Reporting Services.
Question 3: If the model database has the database recovery model set to full, what is the impact?
When new user defined databases are created, they will have a full recovery model. This means that transaction log backups will be needed to maintain a reasonably sized transaction log. If not the transaction logs will continue to grow indefinitely.
Question 5: Does the size of the TempDB database really make a difference and how should TempDB be sized?
In situations where temporary objects are created in T-SQL code (i.e. temporary tables (#temptable or ##temptale), table variables, cursors, work tables, row versioning, create or rebuild indexes sorted in TempDB, etc.) the TempDB database makes a significant difference in overall performance. In these situations the database should be sized appropriately and moved to a separate disk drive in order to support the IO requests. If not, the default location and size may be appriopriate.
In situations where TempDB is not used in the applications, then
Question 4: Can you explain the differences in restoring the Master database versus a user defined database?
In order to restore the Master database the SQL Server instance must be in single user mode.
After the Master database is restored, the SQL Server instance restarts.
A different set of restore errors may occur as compared to user defined databases. One example is if different databases exist from the backup to the current time period, errors will be recorded related to suspect databases.
Question 5: What is the Resource database and in what version of SQL Server was it introduced?
The Resource database is responsible for physically storing all of the SQL Server 2005 system objects. This database has been created to improve the upgrade and rollback of SQL Server system objects with the ability to overwrite only this database.
The Resource database was introduced in SQL Server 2005.