0% found this document useful (0 votes)
179 views

SQL Server Architecture by MAME

SQL Server Architecture and download freely. Happy learning!!

Uploaded by

Mykaa Dba
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
179 views

SQL Server Architecture by MAME

SQL Server Architecture and download freely. Happy learning!!

Uploaded by

Mykaa Dba
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

MAME TECHNOLOGIES

SQL Server Architecture Diagram:

What Is SQL Server?


SQL Server is a relational database management system (or RDBMS) developed by
Microsoft.
SQL Servers provide high-performance data storage. They manage massive data sets
across every computer attached to a network.
SQL Server Architecture
Three primary components make up SQL Server architecture:
1.Protocol Layer,
Relational Engine, and
Storage Engine

Protocol Layer

This layer supports three kinds of Client Server Architecture, plus a stream.

• Shared Memory. The client and SQL server run on the same machine and can
communicate by a shared memory protocol.

1|Page
MAME TECHNOLOGIES
• TCP/IP. This protocol allows the client and SQL server to interact even though they
are installed on separate machines and are remote to each other.

• Named Pipes. This protocol lets the client and SQL server via a Local Area Network
(LAN).

• TDS. All three protocols use Tabular Data Stream packets. These packets allow data
transfers from the client machine to the server machine.

Relational Engine

It's also called the Query Processor, and it contains the SQL Server components that
determine precisely what a query must do and how to best accomplish it. The relational
engine executes user queries by requesting data from the storage engine and
processing the returned results. The engine has three major components:

• CMD Parser: The CMD Parser’s chief purpose is to check the query for Semantic
and Syntactic errors, then generate a Query Tree. The Parser is the first Relational
Engine component to receive Query data.

• Optimizer: The Optimizer works on built-in exhaustive and heuristic algorithms to


ultimately minimize query run times and create an execution plan. Note that the
Optimizer finds the cheapest plan, not the best one.

• Query Executor: The Executor creates the data fetching logic’s execution plan. When
the Executor receives the data from the Storage Engine, the result is published to the
Protocol layer. After the results are published, the resulting data goes to the end-
user.

Storage Engine

Storage Engine stores the data in a storage system such as SAN or a disk and retrieves
it when needed.

• File Types. The Storage Engine has three files: the Primary, Secondary, and Log
files.

• Access Method. This component interfaces between the query executor and the
buffer manager and transaction logs.

2|Page
MAME TECHNOLOGIES
• Buffer Manager. This component manages the core functions for the following three
modules:

• Plan Cache. The buffer manager looks for the existing execution plan stored in the
Plan Cache.

• Data Parsing. The buffer manager then provides access to the needed data.

• Dirty Pages. These pages hold the Transaction Manager’s processing logic data.

• Transaction Manager. The Transaction Manager activates when there are Non-
Select Transactions and manages these transactions using Log and Lock Managers

Buffer Manager

The SQL Server Buffer Manager handles core functions for the plan cache, data
parsing, and dirty pages.

Plan Cache

3|Page
MAME TECHNOLOGIES
First and foremost, the Manager checks whether there is an existing execution plan
stored in the Plan Cache. If there is one, it is used along with the associated data.

Please note that the storage of a query execution plan in the Plan Cache ensures faster
availability whenever your SQL Server receives the same query next time. This is
especially useful for more complex queries.

Data Parsing

The Buffer Manager enables access to the requested data. If there is an execution plan
in the Plan Cache, we have a case of soft parsing. The data is present in the Data
Cache, and it is used by the Query Executor. This method boasts better performance
because of the reduced number of I/O operations.

If there is no execution plan in the Plan Cache, we have a case of hard parsing, when
data must be retrieved from the data storage.

4|Page
MAME TECHNOLOGIES

Transaction Manager

The Transaction Manager is invoked when the query comprises a non-SELECT


statement. It manages the transaction using the Log Manager and the Lock Manager.
The former keeps track of all updates in the system using transaction logs. The latter
locks the involved data during each transaction, ensuring compliance with the ACID
properties.

5|Page
MAME TECHNOLOGIES

A special mention should be made here of write-ahead logging (WAL), which facilitates
atomicity and durability (two of the ACID properties) in database systems. Its general
principle is as follows: before your changes are written to the database, they are first
recorded in the log, which, in turn, is written to stable storage. And if you have a detailed
log of what you did, you can do it again and rebuild all of your data from scratch.

SQLOS

Now here are a few words about the role of SQLOS in the SQL Server architecture.

The SQL Server Operating System is an application layer that underlies the SQL Server
database engine layer. It handles quite a few critical scheduling and resource
management tasks:

• Scheduling of threads for CPU consumption and I/O completion


• Thread synchronization
• Memory allocation and consumption control (whenever Plan Cache, Lock Manager,
or other components request memory from SQLOS)
• Tracking of extended events
• Exception handling (both user- and system-generated)
6|Page
MAME TECHNOLOGIES
• Deadlock detection mechanism
• Hosting of services and memory management for external components

SQL Server Version History and Editions

SQL Server has been around for over three decades and has been through a few
versions.

• 1989. Microsoft and Sybase released version 1.0

• 1993. Microsoft and Sybase end their partnership, but Microsoft keeps SQL Server’s
rights

• 1998. Microsoft releases SQL Server 7.0, a major rewrite

• 2000. Microsoft releases SQL Server 2000

• 2005. Microsoft releases SQL Server 2005

• 2008. Microsoft releases SQL Server 2008

• 2010. Microsoft releases SQL Server 2008 R2, adding new services and a master
data management system

• 2012. Microsoft releases SQL Server 2012

• 2014. Microsoft releases SQL Server 2014

• 2016. Microsoft releases SQL Server 2016

• 2017. Microsoft releases SQL Server 2017, including Linux support

• 2019. Microsoft releases SQL Server 2019, introducing Big Data clusters

• 2022. SQL Server 2022 is the latest version of SQL Server released at the PASS
Data Community Summit on November 16, 2022.

7|Page
MAME TECHNOLOGIES

SQL Server comes in the following popular editions:

• SQL Server Enterprise. Designed for high-end, large-scale, mission-critical


business operations. It offers advanced analytics, high-end security, and Machine
Learning, to name a few

• SQL Server Standard. Best suited for mid-tier applications and data marts and
includes basic reporting and analytics

• SQL Server WEB. Designed to give Web hosts a low total cost-of-ownership option.
It offers affordability, scalability, and management capabilities for small to large-scale
Web properties

• SQL Server Developer. Like the Enterprise edition but designed for non-production
environments and chiefly used for builds, tests, and demos

• SQL Server Express. An open-source, entry-level offering designed for small-scale


applications

MS SQL Server as Client-Server Architecture

The client is an application that gives requests to the MS SQL Server, which resides on
a specific machine. The server can process input data based on the request. At last, the
server responds with processed output data.

Therefore, it’s a simple matter to say that the client is the party making the request, and
the server is the party that initiates the process that eventually meets that request.

The Components of SQL Server Architecture

MS SQL Server consists of a series of services and components:


8|Page
MAME TECHNOLOGIES
• Database Engine: This component is responsible for storage, securing data, and
rapid transaction processing.

• SQL Server: This service starts, stops, pauses, and continues Microsoft SQL Server
instances (which we’ll cover later). Its executable name is sqlservr.exe.

• SQL Server Agent: This agent assumes the role of task scheduler and triggers
either with any event or on-demand. Its executable name is sqlagent.exe.

• SQL Server Browser: This browser listens to incoming requests and connects them
to the needed SQL server instance. Its executable name is sqlbrowser.exe.

• SQL Server Full-Text Search: This search allows users to run full-text queries
against character data residing in SQL Tables. Its executable name is
fdlauncher.exe.

• SQL Server VSS Writer: This component allows data file backup and restoration
when the SQL server isn’t running. Its executable name is sqlwriter.exe.

• SQL Server Analysis Services (SSAS): This service provides data analysis, data
mining, and Machine Learning functions. SQL Server is integrated with the R and
Python programming languages for advanced analytics purposes. Its executable
name is msmdsrv.exe.

• SQL Server Reporting Services (SSRS): This service provides reporting features
and decision-making capabilities, including Hadoop integration. Its executable name
is ReportingServicesService.exe.

• SQL Server Integration Services (SSIS): Finally, this service provides extract-
transform and load capabilities of different data types between sources. In short, it
converts raw information into useful information. Its executable name is
MsDtsSrvr.exe.

Here Are the Advantages of SQL Server Instances:

1. You Can Install and Run Different Versions on One Machine

First, you can have various versions of SQL Server running on a single machine, and
each installation works independently of the others.

2. You Can Reduce Costs

9|Page
MAME TECHNOLOGIES
Instances help reduce the costs of operating SQL Server, especially when you’re
purchasing an SQL Server license. Users get different services from different instances,
so there’s no need to buy one license for all services.

3. You Can Maintain Development, Production, and Test Environments Separately

If you have many SQL Server instances on a single machine, you can assign different
instances to development, production, and test tasks.

4. You Can Reduce Temporary Database Problems

If you have all your services running on a single SQL Server instance, there’s a greater
chance of recurring problems. But when your services run on different instances, you
avoid these problems.

5. You Can Separate Security Privileges

You can pay closer attention to securing an instance running the most sensitive service,
even when you have different services running on other SQL Server instances.

• You Can Maintain a Standby Server

If a SQL Server instance fails, it can result in a service outage. But if you have a
standby server, you’re covered if the current server goes down. You can easily achieve
this service level by using SQL Server instances.

Uses of SQL Server

The modern world continues to generate new data at a breathtaking rate, so we need
databases to hold the information and database management systems to help get the
most use and value out of that information. As a database management system, SQL
Server's services include:

• Creating databases

• Maintaining databases

10 | P a g e
MAME TECHNOLOGIES
• Analyzing data through SQL Server Analysis Services (SSAS)

• Creating reports with SQL Server Reporting Services (SSRS)

• Carrying out ETL operations (Extract, Transform, and Load) with SQL Server
Integration Services (SSIS)

SQL server architecture consists of the following:

1. Page Architecture

2. Database Architecture

3. Network Architecture

4. SQL query execution Architecture

Now, let’s explore each component thoroughly.

1. Page Architecture:

SQL Server uses a storage architecture that is based on the concept of pages.
Understanding the SQL Server’s page architecture is crucial for efficient data storage
and retrieval. Here are some key points about SQL Server’s page architecture:

A page is the fundamental unit of data storage in SQL Server. Each page is 8 KB in size.
Pages are used to store data, indexes, and other database objects. There are several
types of pages in SQL Server, including data pages, index pages, and allocation pages.

The information within the database is stored in the smallest unit known as a ‘data page.’
Each data page comprises a page header, data rows, and row offsets.

11 | P a g e
MAME TECHNOLOGIES
· Page Header: It contains crucial information about the page’s structure and usage. It
typically includes details like the page type, the amount of free space available on the
page, a pointer to the next page, the page number, and other administrative information.

· Data Row: A fundamental unit of data storage within a data page that holds the actual
data.When data is stored on many pages, those series of pages are known as allocation
units.

· Row offset: The “row offset” or “row offset array” is a component of a data page that
stores offset values, indicating the starting location of individual data rows within that
page. Each data page in SQL Server is organized into multiple sections, and one of
these sections is the row offset array.

2. Database Architecture:

In SQL database architecture, there is mainly two component that needs to be


understood properly.

1. Database Files

2. Database Filegroups

1. Database Files:

The file architecture is an important aspect of how data is stored and managed. There
are typically two types of files involved: data files and log files. Let’s explore the
architecture of SQL database files:

A. Data Files:

Data files contain actual data of the database, including tables, indexes, store
procedures, views, and other database objects.

12 | P a g e
MAME TECHNOLOGIES
There are two types of data files:

1. Primary Datafile

2. Secondary Datafile

1. Primary Datafile

· The primary data file stores the initial and default data of the database. When you
create a new database, SQL Server creates a primary data file to hold this data.

· Primary data files are commonly given the file extension ‘.mdf’.

· System tables, system views, and other system objects that are used to manage the
database are also stored in the primary data file.

· Every database has one primary data file.

· Primary data files are part of the primary filegroup.

2. Secondary Datafile

· Secondary data files are additional data files that you can add to a database to store
user data.

· Primarily used to distribute data across multiple file groups, which can improve
database performance and manageability.

· Secondary data files typically have the file extension ‘.ndf’.

· Secondary data files are part of a user-defined filegroup.


13 | P a g e
MAME TECHNOLOGIES
· By adding secondary data files to different filegroups, you can distribute data across
multiple disks or storage devices. This can improve I/O performance by parallelizing data
access.

B. Log Files:

log files are an essential component of database management. They serve several
crucial purposes, including recording changes to the database, ensuring data integrity,
and providing a mechanism for disaster recovery.

· The transaction log file, often with the ‘.ldf ‘file extension, is a critical component of SQL
Server databases.

· It stores a record of all changes made to the database, including INSERT, UPDATE,
and DELETE statements, as well as other operations like index maintenance.

· The transaction log file is essential for maintaining the ACID properties (Atomicity,
Consistency, Isolation, Durability) of a relational database.

· There must be at least one log file for each database.

2.Database File Groups:

Filegroups are logical containers for data files, and they provide a level of organization
and control within a database. Each filegroup can contain one or more data files.

Every SQL Server database has a primary filegroup. The primary filegroup contains the
primary data file (MDF) by default. This filegroup is the default location for objects unless
explicitly specified.

In addition to the primary filegroup, you can create user-defined filegroups. These allow
you to distribute data across different sets of data files.

14 | P a g e
MAME TECHNOLOGIES

If we add two secondary data files in a separate file group, the SQL server stores data in
data files (.ndf) on round round-robin basis.

Data Stored in Datafile as Extents. Extent is a combination of 8 contiguous pages. 8*8 =


64kb

There are 2 types of extents.

1. Uniform Extent: The data Page belongs to one object.

2. Mixed Extent: The data Page is shared by different objects.

3. Network Architecture:

SQL Server’s network architecture is designed to allow clients to communicate with the
SQL Server database engine over a network. This architecture is based on the client-

15 | P a g e
MAME TECHNOLOGIES
server model, where clients (applications or other servers) send requests to the SQL
Server for data retrieval, manipulation, and other database operations.

SQL server uses three different protocols for connection.

1. Shared Memory: Used when the client and server run on the same computer.

2. TCP/IP: Used when the client and server are on different locations and remote to each
other and connected with WAN. The default port is 1433.

3. Named Pipe: When client and server are in connection to LAN, the same kind of
physical network but neighbors. This option is disabled by default. Need to be enabled
by the SQL configuration manager.

All three protocols use a TDS (Tabular Data Stream). TDS is encapsulated in network
packets. This enables the data transfer from the client machine to the server machine.

TDS was first developed by Sybase and is now owned by Microsoft.

4. SQL Query Execution Architecture:

The Relational Engine is a key component responsible for managing and processing
relational database operations. This engine is responsible for a variety of functions
related to the execution of SQL queries and the management of data within the
database.

Below are some of the essential components and functions of the SQL Server Relational
Engine:

1. Query/CMD Parser:

16 | P a g e
MAME TECHNOLOGIES
The query parser is responsible for analyzing SQL queries to check for syntactic
correctness and validity. It also identifies the objects referenced in the query.

2. Query Optimizer:

The query optimizer is a critical component that determines the most efficient way to
execute a given SQL query. It evaluates different execution plans based on factors
suchAs available indexes, statistics, and system resources.

3. Query Executor:

Once an optimized query plan is generated by the query optimizer, the query executor is
responsible for executing the plan. It retrieves data from the database, applies filters and
joins, and returns the result set to the user.

These components work together to ensure that SQL Server effectively manages and
processes relational database operations while maintaining data consistency, security,
and performance.

17 | P a g e

You might also like