Datasheet
SQL Server is a relational database consisting of many components, each of which contains multiple
objects. In the following sections, you examine the main objects that make up a SQL Server database.
While you will not examine each and every object of a database, rest assured that what you do learn here
will serve you well, laying the foundation for what you will be doing throughout the rest of this book.
A SQL Server database consists of at least two files: a data file and a log file. The data file contains all the
data that makes up a SQL Server database, such as tables, indexes, and stored procedures. You examine
these objects shortly. The log file contains transaction logs, which are records of changes made to the
database.
When you initially create a SQL Server database, the data file and log file are created by SQL Server; the
data file has an
.mdf extension and the log file has an .ldf extension. As your database grows and you
run out of room on the hard drive, your database administrator may create a secondary data file on a
separate hard drive. It will typically have an
.ndf file extension. Creating a secondary data file for a
database typically happens only with large enterprise databases, as most hard drives today can hold
multiple database files on a single drive, given the drives extremely large capacity.
Data files
The data file contains multiple objects that make up a database. Table 1-1 lists the various objects that
make up a database and are contained in the data file. While you will not be exploring each of these
objects in detail, it is helpful to know that they exist and what they do.
Table 1-1: SQL Server Data File Objects
Object Description
Tables Contains the data in a database, organized in a row-column
format.
Keys Primary keys provide a unique value for each row of data in a
table. Foreign keys provide a relationship between two tables
using a column in one table and the primary key in another table.
Indexes Provides pointers to rows in a table in a similar fashion that the
index in this book provides pointers to specific topics.
Constraints Provides a means by which you can enforce the integrity of a
database, such as not allowing a column to contain a NULL value.
Stored Procedures A single SQL statement or group of SQL statements
compiled into a single execution plan.
Views A SQL SELECT statement that returns a virtual table.
Triggers A special class of stored procedures that are automatically
executed when an
Insert, Update, or Delete statement
is executed against a table.
Defaults A default value that is inserted into a column in a table when no
value is supplied.
4
Chapter 1
04_58894x ch01.qxd 10/13/05 5:54 PM Page 4










