You are on page 1of 4

Page |1

Chapter 4: Designing Databases


After completing this chapter, you will be able to: a. b. c. d. e. Understand the function of each system database Create a database Define and add filegroups to a database Add files to filegroups Detach and Add databases

1. Databases are the primary objects within SQL Server for both the relational engine as well as SQL Server 2008 Analysis Services (SSAS). In this chapter, we will learn how to create databases along with the fundamentals of data storage. You will learn about the different types of filegroups that can be created for a database and how each type affects the way data is stored and handled. 2. Since all data within SQL Server has to be stored inside a database, information about the SQL Server instance and any objects that the instance contains also have to be stored in databases. We will describe each of the system databases that ships with SQL Server and its role within the SQL Server platform.

SQL Server System Databases


SQL Server 2008 ships with a set of system databases used to manage various aspects of the database engine. a. b. c. d. e. Master Msdb Tempdb Model Distribution

1. The master database lies at the very heart of every SQL server instance. Without the Master database, SQL Server cannot run. The Master database contains information about the core objects within an instance such as: a. Databases b. Logins c. Configuration Options d. Endpoints

Page |2
e. Server-level DDL triggers f. Linked Servers 2. The model database is a template, used by SQl Server, when you create a new database. When you issue a CREATE database command, SQL server takes the definition of the model database and applies it to the new database that you are create. The purpose of the model database is to allow administrators to create objects which will automatically be added to any new database that is created. 3. 4. The MSDB database is used by SQL Server Agent along with SSIS. The central role of the msdb database is to store the jobs and the schedules to be executed by the SQL Server Agent. Within the msdb database you will find the following: a. Database Engine Tuning Advisor, DTA reports Chapter 29 b. History of any backups/restore executed against any database c. Tracking information for log shipping d. Jobs, Job Steps, Schedules e. Alerts f. Proxy Accounts g. Maintenance Plans h. SSIS packages i. Database Mail Logs 5. The Temp DB is a Universal scratch area within SQL server. The SQL Server engine uses the temp database as the temporary storage area to perform aggregation operations. When you restart a new instance of SQL Server, all of the data within the temp database is automatically wiped out.

SQL Server Database Structure


The objects that are created within a database are collectively referred to as the database structure. The elements that define a database, the storage components are referred to as the database structure. A SQL Server database is defined using three things: a. One physical element b. Files on the operating system

Page |3
c. One logical element used to group files within a database.

Database Files
The most common file types supporting a SQL Server database are data files and transaction log files. The default file extensions for data files are: a. .mdf primary file b. .ndl secondary file c. .ldf transaction log file

File groups
A file group is nothing more than a name for a collection of operating system files. Database objects are created on a filegroup and the SQL server engine takes care of distributing data across a collection of files. The transaction log file receives special handling within a SQL server instance. A data file is associated with a file group. A transaction log file is not associate with any file group within a database. You can create 3 types of filegroups within a SQL Server instance: a. Data b. Full-text c. FILESTREAM

CHAPTER 4: Quick Reference


a. To Create a new database, use the CREATE database command b. Add storage to a database by adding one or more files to an existing filegroup or adding one or more filegroups that contain at least one file. c. In order to set one of more filegroup to be used by default when storage options are not specified while creating an index or a table, assign the DEFAULT property to the filegroup. d. To enable a database to store FILESTREAM data, create a database with a filegroup designated with the option CONTAINS FILESTREAM OR you can add a filegroup to an existing database designed for FILESTREAM storage. e. In order to DETACH, execute the sp_detach_db system stored procedure

Page |4
f. In order to attach a database, execute a CREATE DATABASE with the FOR ATTACH option.

You might also like