SQL Lecture

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 23

• It is the Online Transaction

Processing (OLTP) engine for SQL Server

• The Database Engine is a high-performance


component responsible for the efficient storage,
retrieval, and manipulation of relational and Extensible
Markup Language (XML) formatted data.

• SQL Server 2005’s Database Engine is highly optimized


for transaction processing, but offers exceptional
performance in complex data retrieval operations.
 Physical partitioning of tables and indexes—
Tables and indexes can now be physically partitioned
across multiple file groups consisting of multiple
physical files.

 Data Definition Language (DDL) triggers—DDL


triggers can be used to execute commands and
procedures when DDL type statements are
executed

 Enhanced variable-length data types—A new MAX


keyword has been added to varchar,nvarchar, and
varbinary data types that allow the allocation of up
to 2GB of space for large object variables
XML data type—The new XML data type enables the
storage of well-formed and schema validated XML data.

Multiple Active Result Sets (MARS)—MARS allows


for clients to maintain more than one data request per
connection.

Structured error handling—T-SQL now includes the


ability to perform structured error handling
in the form of TRY and CATCH commands
Common Table Expressions:-CTEs are
extraordinarily useful in the creation of efficient
queries that return hierarchical information without
the need for using lengthy and complicated
recursive sub-queries

Security enhancements:-Logins, encryptions,


digital signature.

Common Language Run-Time (CLR) integration


Analysis Services delivers Online Analytical
Processing (OLAP) and Data Mining functionality
for business intelligence applications.

Analysis Services provides a very robust


environment for the analysis of large quantities
of data. It does this through user-created,
multidimensional data structures that contain de-
normalized and aggregated data from diverse
data sources
 Reporting Services is a Web service–based
solution for designing, deploying, and
managing flexible,
 dynamic Web-based reports, as well as
traditional paper reports. These reports can
contain information
 from virtually any data source
SQL Server Integration Services (SSIS) is Microsoft’s
new enterprise class data Extract, Transform, and
Load (ETL) tool.
Notification Services

Notification Services’ applications provide the


mechanism for subscribers to create a subscription
for a specific event, which could be a database, file
system, or some other programmatic event. The
notification can take the form of an email or other
custom delivery methods
Replication Services:-
SQL Server 2005 Replication Services provides the
ability to automate and schedule the copying and
distribution of data and database objects from one
database or server to another, while ensuring data
integrity and consistency.

Multiple Instances:-
SQL Server 2005 provides the capability of installing
multiple instances of the database application on a
single computer. Depending on the edition of SQL
Server being installed, up to 50 instances can be
installed
SQL Server 2005 Database Objects:-

Server:-

The server scope encompasses all the objects that exist


on the instance of SQL Server, regardless of their
respective database or namespace. The database object
resides within the server scope.

When it comes to the server scope and SQL Server 2005


database objects, the term “server” actually refers
to the SQL Server 2005 instance name.
Database:-
The database scope defines all the objects within a
defined database catalog. Schemas exist in the
database scope. An instance of SQL Server 2005
can contain many databases.
Schema:-
Each database can contain one or more schemas.
A schema is a namespace for database objects. All
data objects in a SQL Server 2005 database reside
in a specific schema. A database schema is a
defined namespace in which database objects
exist. Permissions can be granted to a schema,
and those permissions will be inherited by all the
objects defined in the schema
Object Names:-
Every object in a SQL Server 2005 database is
identified by a four-part, fully qualified name. This
fully qualified name takes the form of
server.database.schema.object
• By omitting the server name SQL Server will
assume the instance the connection is currently
connected to.
• Omitting the database name will cause SQL Server
to assume the existing connection’s database.
• Omitting the schema name will cause SQL Server
to assume the namespace of the logged-in user. It is
completely possible to create a table with the same
name in two different schemas
SQL Server 2005 Databases:-
There are two types of databases in SQL Server:
system databases and user databases. The system
databases are used to store system-wide data and
metadata. User databases are created by users who
have the appropriate level of permissions to store
application data.

System Databases:-
The system databases are comprised of Master, Model,
MSDB, TempDB, and the hidden Resource
Database.
The Master Database:-
The Master database is used to record all server-
level objects in SQL Server 2005. This includes
Server Logon accounts, Linked Server definitions,
and EndPoints.

The Master database also records information about


all the other databases on the server.

SQL Server 2005 does not store system information


in the Master database, but rather in the Resource
database. However, system information is logically
presented as the SYS schema in the Master database
The Model Database:-
The Model database is a template database. Whenever a
new database is created (including the system
database TempDB), a copy of the Model database is
created and renamed with the name of the database
being created. The advantage of this behavior is that
objects can be placed in the Model database prior to
the creation of any new database and, when the database
is created, the objects will appear in the new database.

The MSDB Database:- the SQL Server


Agent uses the MSDB database extensively for the
storage of automated job definitions, job schedules,
operator definitions, and alert definitions.
The TempDB Database:-
The TempDB database is used by SQL Server to store
data temporarily. The TempDB database is used
extensively during SQL Server operations, so careful
planning and evaluation of its size and placement are
critical to ensure efficient SQL Server database operations.

The Resource Database:- The Resource database is a


read-only database that contains all the system objects
used by an instance of SQL Server. It contains no user
data or metadata. Instead, it contains the structure and
description of all system object.

User Databases
Capacity Planning:-

Add up the total number of bytes used by the fixed-


length columns in the table.

2. Average the total number of bytes used by the


variable-length columns in the table.

3. Add the number from Step 1 to the number


calculated in Step 2.

4. Divide 8092 (the maximum amount of data bytes in a


page) by the number calculated in Step 3,
and round down to the nearest whole number. This is
number of rows that will fit on a single page.
5. Divide the total number of expected rows by the number of
rows per page calculated in Step 4.This is the total number of
data pages expected to support the table.

6. Multiply the number calculated in Step 5 by 8192 (the size of


data page). This is the total numberof bytes required for the
table.

7. Repeat the process for every table in the database.


A failover cluster is a group of independent
computers that work together to increase the
availability of applications and services. The
clustered servers (called nodes) are connected by
physical cables and by software. If one of the cluster
nodes fails, another node begins to provide service (a
process known as failover). Users experience a
minimum of disruptions in service.
Data Files and Filegroups

When a user database is created, it must contain at


least one data file. This first data file is known as the
primary data file. The primary data file is a member of the
default Primary filegroup. Every database has
one Primary filegroup when created and is made up of
at least the primary data file.

Additional data files can also be added to the Primary


filegroup. More filegroups can also be defined upon
initial creation of the database, or added after the
database is created.

Data files can be logically grouped to improve


performance and allow for more flexible maintenance
Log Files:-
• Upon initial creation of a database, one transaction log
must be defined. The transaction log is used to record all
modifications to the database to guarantee transactional
consistency and recoverability.

• Although it is often advantageous to create multiple data


files and multiple filegroups, it is very rarely necessary to
create more than one log file. This is because of how SQL
Server accesses the files. Data files can be accessed in
parallel, enabling SQL Server to read and write to multiple
files and filegroups simultaneously.

•Log files are serialized to maintain transactional


consistency. Each transaction is recorded serially in the log in
the sequence it was executed. A second log file will not be
accessed until the first log file is completely filled.
Processor Considerations:-
Microsoft sets the minimum processor at a 600 MHz Pentium
III or compatible processor but recommends at least a 1 GHz
processor. SQL Server utilizes the processor extensively
during the compilation and execution of query plans.

Memory Considerations
The minimum amount of RAM, according to Microsoft,
is 512MB SQL Server likes memory—a lot. It attempts to
place as much data as possible in RAM so that the data is
readily available for processing.

SQL Server creates and maintains different memory


pools for various database operations.
• For example,there is a buffer cache that is used to
store data pages retrieved from the disk; a procedure cache
that is used to store compiled stored procedures,
triggers, functions, views, and query plans; and even
a log cache for transaction log operations.

• Having sufficient RAM on hand allows SQL Server


to minimize the amount of page swapping required
and enables the data to be pre-fetched for fast
processing.
Storage Considerations:-

It is definitely a best practice to separate the data files


of a database from the log file. If the database is
corrupted or damaged, the most recent backup can be
used to recover it, and then the existing transaction log
can be used to recover all the transactions since the last
backup. Likewise, if the transaction log is lost, it can be
re-created with minimal data loss from the database

You might also like