Chapter 4 - Part II - Create A Database
Chapter 4 - Part II - Create A Database
Chapter 4 - Part II - Create A Database
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.
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.
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
Page |4
f. In order to attach a database, execute a CREATE DATABASE with the FOR ATTACH option.