Database in SQL Server 2022
Database in SQL Server 2022
1. Database Architecture
2. System Databases
3. Data Files
4. Log Files
5. Extents
6. Pages
Work with databases use the SQL Server Management Studio tool.
The Management Studio tool has a graphical user interface for creating
databases and the objects in the databases.
System Databases:
When we install MS SQL Server on our system, the system databases are created
automatically. It plays an important role for the server to function properly.
Mayukha IT Services
[email protected]
+91-9573349020
https://realtimedba.thinkific.com/courses/your-first-course\
https://www.linkedin.com/in/mayukhaitservices/
The following is a list of SQL Server's system databases:
1. Master,
2. Model,
3. MSDB,
4. Tempdb,
5. Resource DB(Hidden state) –Files Server in default
Mssqlsystemresource.mdf
Mssqlsystemresource.ldf
User Databases:
These databases are created by database users like DBAs and testers who can
also access and manipulate their data.
Mayukha IT Services
[email protected]
+91-9573349020
https://realtimedba.thinkific.com/courses/your-first-course\
https://www.linkedin.com/in/mayukhaitservices/
o Transact-SQL Command
o SQL Server Management Studio (SSMS)
o Transact-SQL Command
master Records all the system-level information for an instance of SQL Server.
Database
msdb Is used by SQL Server Agent for scheduling alerts and jobs.
Database
model Is used as the template for all databases created on the instance of SQL Server.
Database Modifications made to the model database, such as database size, collation,
recovery model, and other database options, are applied to any databases
created afterward.
Resource Is a read-only database that contains system objects that are included with SQL
Database Server. System objects are physically persisted in the Resource database, but they
logically appear in the sys schema of every database.
tempdb Is a workspace for holding temporary objects or intermediate result sets.
Database
Database Architecture
Mayukha IT Services
[email protected]
+91-9573349020
https://realtimedba.thinkific.com/courses/your-first-course\
https://www.linkedin.com/in/mayukhaitservices/
Logical Component
Logical components comprises of following:
Database objects,
Collation,
Login, Users, Roles and groups.
Physical component
Physically components exist as two or more files on disk.
Physically files can be of three types.
Log files
It contains log information which is used to recover database.
Database files are used for mapping the database over some operating system
files. Data and log information are separate.
Mayukha IT Services
[email protected]
+91-9573349020
https://realtimedba.thinkific.com/courses/your-first-course\
https://www.linkedin.com/in/mayukhaitservices/
Secondary: All data files except primary data file is a part of secondary files.
Extension: .ndf
Log files: All log information used to recover database. Extension: .ldf
File Groups
Database files can be grouped together in file groups for allocation and
administration purposes. No file can be a member of more than one file group.
Log files are never part of a file group. Log space is managed separately from data
space.
There are two types of file groups in SQL Server, Primary and User-defined.
Primary file group contains the primary data file and any other files not
specifically assigned to another file group. All pages for the system tables are
allocated in the primary file group
Extents
Extents are basic unit in which space is allocated to tables and indexes. An extent
is 8 contiguous pages or 64KB. SQL Server has two types of extents - Uniform and
Mixed. Uniform extents are made up of only single object. Mixed extents are shared
by up to eight objects.
Pages
It is the fundamental unit of data storage in MS SQL Server. The size of the page is
8KB. The start of each page is 96 byte header used to store system information
Mayukha IT Services
[email protected]
+91-9573349020
https://realtimedba.thinkific.com/courses/your-first-course\
https://www.linkedin.com/in/mayukhaitservices/
such as type of page, amount of free space on the page and object id of the object
owning the page. There are 9 types of data pages in SQL Server.
Data − Data rows with all data except text, ntext and image data.
Index − Index entries.
Tex\Image − Text, image and ntext data.
GAM − Information about allocated extents.
SGAM − Information about allocated extents at system level.
Page Free Space (PFS) − Information about free space available on pages.
Index Allocation Map (IAM) − Information about extents used by a table
or index.
Bulk Changed Map (BCM) − Information about extents modified by bulk
operations since the last backup log statement.
Differential Changed Map (DCM) − Information about extents that have
changed since the last backup database statement.
Database Objects
Table - Object that holds the relational data.
Mayukha IT Services
[email protected]
+91-9573349020
https://realtimedba.thinkific.com/courses/your-first-course\
https://www.linkedin.com/in/mayukhaitservices/
also run DELETE/INSERT/UPDATE, stored procedures can have both input
and output parameters whereas functions can only have input, functions
can be used in one or many parts of a SELECT query and stored procedures
cannot be used, stored procedures can optionally return a value whereas
function must return a value, etc.
Index - This is a structure that can be used to speed up accessing data in a
table. Specified columns make up the index and, when specified in a
query, can help to speed up performance as the indexed column will
contain a pointer to where the rest of the data is located that makes up
that row.
User/Login - Sometimes used interchangeably in SQL Server they are in
fact two different things. A login is used for authentication to the database
instance whereas a user is used for database/object access. Each login will
have an associated database user (most often with the same name).
Role - An object that contains a set of permissions for objects within the
database. Can be granted to users to ease administration by not having to
grant individual permissions to each user.
Schema - Schema can have many different meanings in a database context
but here it can be described as something that holds a collection of
objects, kind of like a container or namespace. Other objects like tables,
indexes, function, etc. can be grouped logically and assigned to a schema
on creation.
Mayukha IT Services
[email protected]
+91-9573349020
https://realtimedba.thinkific.com/courses/your-first-course\
https://www.linkedin.com/in/mayukhaitservices/