Tag: Databases

Design and implement JSON columns and indexes (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Design and develop database solutions (35–40%)
   --> Design and implement database objects
      --> Design and implement JSON columns and indexes


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

JSON (JavaScript Object Notation) has become one of the most widely used formats for exchanging data between applications, web services, APIs, cloud platforms, and AI solutions. Modern database applications frequently need to store, query, validate, and index JSON documents alongside traditional relational data.

SQL Server and Azure SQL Database provide extensive built-in support for working with JSON, allowing developers to:

  • Store JSON documents
  • Validate JSON data
  • Query individual properties
  • Modify JSON documents
  • Convert relational data to JSON
  • Convert JSON into relational tables
  • Improve performance by indexing JSON values

For the DP-800: Developing AI-Enabled Database Solutions certification exam, understanding how JSON is stored, queried, and indexed is an important skill because many AI-enabled applications exchange information using JSON.


Why Use JSON?

JSON offers a flexible way to store semi-structured data that doesn’t fit neatly into fixed relational tables.

Common scenarios include:

  • REST API payloads
  • Application configuration
  • Product catalogs
  • Customer preferences
  • Event logs
  • IoT telemetry
  • AI prompts and responses
  • Chat conversation history
  • Metadata storage

Rather than creating dozens of optional columns, JSON allows variable attributes to be stored in a single column.


JSON Support in SQL Server

Unlike some database systems, SQL Server stores JSON as text rather than as a dedicated JSON data type.

Typically, JSON documents are stored in:

  • NVARCHAR(MAX)
  • NVARCHAR(n)

Example:

CREATE TABLE Orders
(
OrderID INT PRIMARY KEY,
CustomerInfo NVARCHAR(MAX)
);

A row might contain:

{
"CustomerID": 125,
"Name": "John Smith",
"City": "Seattle",
"LoyaltyLevel": "Gold"
}

Although stored as text, SQL Server provides built-in functions that understand JSON syntax.


Validating JSON

Before using JSON data, developers should ensure it contains valid JSON.

SQL Server provides the ISJSON() function.

Example:

SELECT ISJSON(CustomerInfo)
FROM Orders;

Returns:

  • 1 = Valid JSON
  • 0 = Invalid JSON

Example using a CHECK constraint:

ALTER TABLE Orders
ADD CONSTRAINT CK_ValidJSON
CHECK (ISJSON(CustomerInfo) = 1);

This prevents invalid JSON from being stored.


Extracting Values with JSON_VALUE()

The JSON_VALUE() function extracts a scalar value from a JSON document.

Example:

SELECT
JSON_VALUE(CustomerInfo,'$.Name')
FROM Orders;

Result:

John Smith

Common uses include:

  • Filtering
  • Sorting
  • Displaying attributes
  • Reporting

Extracting Objects and Arrays with JSON_QUERY()

JSON_QUERY() retrieves an object or array rather than a scalar value.

Example JSON:

{
"CustomerID": 25,
"Orders":
[
{"OrderID":1},
{"OrderID":2}
]
}

Query:

SELECT
JSON_QUERY(CustomerInfo,'$.Orders')
FROM Orders;

Returns the JSON array.


Updating JSON with JSON_MODIFY()

JSON_MODIFY() updates properties without replacing the entire document.

Example:

UPDATE Orders
SET CustomerInfo =
JSON_MODIFY(CustomerInfo,
'$.City',
'Chicago');

Useful when applications maintain customer preferences or AI-generated metadata.


Parsing JSON into Rows with OPENJSON()

OPENJSON converts JSON into relational rows.

Example:

SELECT *
FROM OPENJSON(@json);

Example JSON:

{
"Name":"Alice",
"City":"Boston"
}

Returns:

KeyValue
NameAlice
CityBoston

Using WITH to Define a Schema

OPENJSON becomes much more useful when mapping JSON to columns.

Example:

SELECT *
FROM OPENJSON(@json)
WITH
(
Name NVARCHAR(100),
City NVARCHAR(100),
Age INT
);

This converts JSON directly into relational columns.


Producing JSON with FOR JSON

SQL Server can return query results as JSON.

Example:

SELECT CustomerID,
Name,
City
FROM Customers
FOR JSON AUTO;

Output:

[
{
"CustomerID":1,
"Name":"Alice",
"City":"Boston"
}
]

FOR JSON PATH

FOR JSON PATH provides greater control over the structure.

Example:

SELECT CustomerID,
Name
FROM Customers
FOR JSON PATH;

Developers commonly use this when building REST APIs.


Common JSON Functions

FunctionPurpose
ISJSON()Validate JSON
JSON_VALUE()Return scalar value
JSON_QUERY()Return object or array
JSON_MODIFY()Update JSON
OPENJSON()Convert JSON into rows
FOR JSONProduce JSON output

These functions appear frequently in Microsoft documentation and certification objectives.


Why JSON Indexing Matters

JSON itself is stored as text.

Without indexing, SQL Server must scan every JSON document to locate requested values.

This becomes expensive for large tables.

Example:

SELECT *
FROM Orders
WHERE JSON_VALUE(CustomerInfo,'$.City')='Seattle';

Without indexing, SQL Server evaluates JSON_VALUE() for every row.


Indexing JSON Data

Because JSON is stored in NVARCHAR columns, SQL Server cannot directly create an index on an arbitrary JSON property.

Instead, developers create computed columns that expose JSON properties and then index those computed columns.

This is the recommended approach for SQL Server and Azure SQL Database and is an important DP-800 exam objective.


Creating a Computed Column

Example:

ALTER TABLE Orders
ADD CustomerCity AS
JSON_VALUE(CustomerInfo,'$.City');

SQL Server now treats CustomerCity as a regular column.


Creating an Index

Once the computed column exists, it can be indexed.

Example:

CREATE INDEX IX_Orders_CustomerCity
ON Orders(CustomerCity);

Queries filtering on CustomerCity can now use the index rather than scanning every JSON document.


Persisted Computed Columns

Computed columns may be marked PERSISTED.

Example:

ALTER TABLE Orders
ADD CustomerCity
AS JSON_VALUE(CustomerInfo,'$.City')
PERSISTED;

Benefits include:

  • Value stored physically
  • Faster reads
  • Reduced recalculation

Trade-offs include:

  • Increased storage
  • Slightly slower INSERT/UPDATE operations

JSON Path Expressions

SQL Server identifies JSON elements using path expressions.

Examples:

$.Name
$.Address.City
$.Orders[0]
$.Orders[1].Price

The dollar sign ($) represents the root of the JSON document.

Understanding JSON path syntax is essential for using JSON functions correctly.


Nested JSON

Example:

{
"Customer":
{
"Name":"Alice",
"Address":
{
"City":"Boston"
}
}
}

Extracting City:

SELECT
JSON_VALUE(CustomerInfo,
'$.Customer.Address.City');

Working with JSON Arrays

Example JSON:

{
"Products":
[
{"ID":1},
{"ID":2},
{"ID":3}
]
}

Retrieve the array:

SELECT
JSON_QUERY(OrderInfo,'$.Products');

Convert to rows:

SELECT *
FROM OPENJSON
(
JSON_QUERY(OrderInfo,'$.Products')
);

JSON Design Considerations

JSON is ideal when:

  • Attributes vary significantly between rows.
  • Schema flexibility is required.
  • Data originates from APIs.
  • AI systems generate dynamic metadata.
  • Semi-structured information must be stored.

Relational tables are preferable when:

  • Strong relationships exist.
  • Frequent joins are required.
  • Referential integrity must be enforced.
  • Structured reporting dominates the workload.

Many production databases combine relational columns with JSON columns.


JSON and AI Applications

JSON is heavily used throughout AI-enabled database solutions.

Common examples include:

  • Storing AI prompt templates
  • Saving LLM responses
  • Recording chat history
  • Persisting vector search metadata
  • Storing application configuration
  • Capturing model parameters
  • Logging AI inference results

Because AI services frequently communicate using JSON, SQL Server’s JSON functionality is an important integration capability.


Performance Considerations

When working with JSON:

  • Validate incoming JSON using ISJSON().
  • Avoid repeatedly evaluating JSON_VALUE() in large queries.
  • Create computed columns for frequently queried properties.
  • Index computed columns used in WHERE, JOIN, or ORDER BY clauses.
  • Persist computed columns when read performance outweighs storage costs.
  • Avoid storing extremely large documents unless necessary.
  • Use OPENJSON() for efficient ingestion of structured JSON payloads.

Best Practices

  • Store only valid JSON documents.
  • Keep relational data relational whenever practical.
  • Use JSON for flexible or semi-structured attributes.
  • Use JSON_VALUE() for scalar values.
  • Use JSON_QUERY() for arrays and objects.
  • Use JSON_MODIFY() for updates.
  • Use OPENJSON() to transform JSON into relational rows.
  • Create computed columns for frequently searched JSON properties.
  • Index computed columns to improve query performance.
  • Test execution plans to verify indexes are being used.

Common Exam Tips

For the DP-800 exam, remember these key points:

  • SQL Server stores JSON as NVARCHAR, not as a native JSON data type.
  • ISJSON() validates JSON syntax.
  • JSON_VALUE() returns a scalar value.
  • JSON_QUERY() returns an object or array.
  • JSON_MODIFY() updates JSON documents.
  • OPENJSON() converts JSON into relational rows.
  • FOR JSON AUTO and FOR JSON PATH generate JSON output from SQL queries.
  • JSON properties are typically indexed by exposing them through computed columns and creating indexes on those columns.
  • Persisted computed columns can improve read performance at the cost of additional storage and update overhead.

Practice Exam Questions

Question 1

A developer needs to verify that incoming API payloads contain valid JSON before storing them in a table. Which SQL Server function should be used?

A. JSON_QUERY()

B. OPENJSON()

C. JSON_VALUE()

D. ISJSON()

Answer: D

Explanation: ISJSON() validates whether a string contains properly formatted JSON. It returns 1 for valid JSON and 0 for invalid JSON, making it ideal for validation and CHECK constraints.


Question 2

A developer wants to retrieve the value of the City property from a JSON document stored in an NVARCHAR column. Which function should be used?

A. JSON_VALUE()

B. JSON_QUERY()

C. JSON_MODIFY()

D. OPENJSON()

Answer: A

Explanation: JSON_VALUE() extracts a single scalar value from a JSON document, such as a string, number, or Boolean.


Question 3

Which statement accurately describes how SQL Server stores JSON data?

A. SQL Server stores JSON in a dedicated JSON data type.

B. SQL Server stores JSON as XML internally.

C. SQL Server stores JSON as character data, typically in an NVARCHAR column.

D. SQL Server automatically converts JSON into relational columns.

Answer: C

Explanation: SQL Server does not provide a native JSON data type. JSON documents are stored as text, typically in NVARCHAR(MAX) or NVARCHAR(n) columns.


Question 4

A query frequently filters on the value returned by JSON_VALUE(CustomerInfo,'$.City'). What is the recommended way to improve query performance?

A. Create a clustered index on the JSON column.

B. Create a computed column using JSON_VALUE() and index the computed column.

C. Replace the JSON column with XML.

D. Create a foreign key on the JSON column.

Answer: B

Explanation: SQL Server cannot directly index an arbitrary JSON property. The recommended approach is to expose the property through a computed column and then create an index on that computed column.


Question 5

A developer needs to retrieve an entire JSON array from a document rather than a single scalar value. Which function should be used?

A. JSON_QUERY()

B. JSON_VALUE()

C. ISJSON()

D. JSON_MODIFY()

Answer: A

Explanation: JSON_QUERY() returns a JSON object or array, whereas JSON_VALUE() returns only scalar values.


Question 6

Which SQL Server feature converts relational query results into JSON output?

A. OPENJSON

B. JSON_VALUE

C. FOR JSON

D. JSON_MODIFY

Answer: C

Explanation: The FOR JSON clause formats SQL query results as JSON. Both AUTO and PATH modes are available.


Question 7

A developer receives a JSON document containing thousands of customer records and wants to transform it into relational rows for loading into SQL Server. Which function should be used?

A. JSON_QUERY()

B. JSON_MODIFY()

C. ISJSON()

D. OPENJSON()

Answer: D

Explanation: OPENJSON() parses JSON documents and converts them into rows and columns. It is commonly used for importing JSON data.


Question 8

What is the primary advantage of creating a persisted computed column based on a JSON property?

A. It automatically encrypts the JSON document.

B. It physically stores the computed value, reducing recalculation during queries.

C. It compresses the JSON document.

D. It converts JSON into XML.

Answer: B

Explanation: A persisted computed column stores its calculated value on disk, improving query performance by avoiding repeated evaluation of the expression.


Question 9

Which JSON path expression retrieves the City property nested inside an Address object?

A. $.City.Address

B. $.Address.City

C. $.Address[City]

D. $.City->Address

Answer: B

Explanation: JSON path expressions begin at the root ($) and navigate nested objects using dot notation, such as $.Address.City.


Question 10

Which scenario is the best candidate for storing information in a JSON column instead of creating many optional relational columns?

A. A highly normalized customer master table with strict referential integrity

B. A table containing only integer values

C. A fixed employee payroll table with mandatory attributes

D. A product catalog in which different product categories have different sets of optional attributes

Answer: D

Explanation: JSON is well suited for semi-structured or variable data, such as product attributes that differ across categories, avoiding the need for numerous nullable columns while maintaining flexibility.


Go to the DP-800 Exam Prep Hub main page

Design and implement specialized tables, including in-memory, temporal, external, ledger, and graph tables (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Design and develop database solutions (35–40%)
   --> Design and implement database objects
      --> Design and implement specialized tables, including in-memory, temporal, external, ledger, and graph


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

Modern SQL Server and Azure SQL Database environments provide several specialized table types designed to address specific business, performance, security, and analytical requirements. Rather than relying solely on traditional row-based tables, developers can use specialized tables to improve transaction throughput, maintain historical data automatically, access external data sources, provide tamper-evident records, or model complex relationships.

For the DP-800: Developing AI-Enabled Database Solutions certification exam, you should understand:

  • When to use each specialized table type
  • How each table is implemented
  • Their advantages and limitations
  • Common business scenarios
  • Performance considerations
  • Best practices

Understanding these table types is especially important because many modern AI-enabled applications require historical analysis, secure auditing, graph-based relationships, or access to large external datasets.


Overview of Specialized Tables

SQL Server and Azure SQL support several specialized table types:

Table TypePrimary Purpose
In-Memory TablesHigh-performance OLTP workloads
Temporal TablesAutomatic historical data tracking
External TablesQuery external data without importing it
Ledger TablesTamper-evident data and auditability
Graph TablesModel complex relationships between entities

Each solves a different architectural challenge.


In-Memory Tables

What Are In-Memory Tables?

In-memory tables are stored primarily in memory instead of traditional disk-based storage. They are part of the In-Memory OLTP feature in SQL Server and Azure SQL Database.

Unlike conventional tables, in-memory tables are optimized for extremely fast transaction processing.

They use:

  • Memory-optimized data structures
  • Lock-free algorithms
  • Latch-free architecture
  • Optimistic concurrency

These improvements reduce contention and dramatically improve throughput.


Benefits

Advantages include:

  • Extremely low latency
  • High transaction throughput
  • Reduced locking
  • Reduced blocking
  • Improved scalability
  • Better concurrency

Applications can often process several times more transactions compared to equivalent disk-based tables.


Typical Use Cases

Common scenarios include:

  • Financial trading
  • E-commerce transactions
  • Reservation systems
  • Gaming platforms
  • Real-time telemetry
  • IoT ingestion
  • Session state storage
  • High-volume order processing

Memory-Optimized Filegroup

Although data is stored in memory during operation, SQL Server still requires a memory-optimized filegroup for durability.

Example:

ALTER DATABASE SalesDB
ADD FILEGROUP InMemoryFG CONTAINS MEMORY_OPTIMIZED_DATA;

Creating a Memory-Optimized Table

Example:

CREATE TABLE Orders
(
OrderID INT NOT NULL PRIMARY KEY NONCLUSTERED,
CustomerID INT,
OrderDate DATETIME2
)
WITH
(
MEMORY_OPTIMIZED = ON,
DURABILITY = SCHEMA_AND_DATA
);

Durability Options

SCHEMA_AND_DATA

Both schema and data survive server restart.

Recommended for:

  • Production applications
  • Financial systems
  • Business transactions

SCHEMA_ONLY

Only the table definition persists.

Data disappears after restart.

Useful for:

  • Temporary data
  • Session caches
  • ETL staging
  • Intermediate processing

Memory-Optimized Indexes

Memory-optimized tables require indexes.

Supported types include:

  • Hash indexes
  • Nonclustered indexes

Hash indexes perform exceptionally well for equality searches.

Example:

INDEX IX_Order HASH(OrderID)
WITH (BUCKET_COUNT = 100000)

Limitations

Developers should know:

  • Not every SQL feature is supported.
  • Memory planning is important.
  • Some T-SQL functionality differs.
  • Requires appropriate database configuration.

Temporal Tables

What Are Temporal Tables?

Temporal tables automatically maintain a complete history of data changes.

Whenever a row is:

  • Updated
  • Deleted

SQL Server automatically copies the previous version into a history table.

This eliminates the need for custom audit triggers.


Components

A temporal table consists of:

  • Current table
  • History table
  • System versioning

SQL Server manages the history automatically.


Period Columns

Temporal tables include two hidden datetime columns:

ValidFrom
ValidTo

These define the period during which each row version was valid.


Creating a Temporal Table

Example:

CREATE TABLE Employees
(
EmployeeID INT PRIMARY KEY,
Name NVARCHAR(100),
Salary DECIMAL(10,2),
ValidFrom DATETIME2 GENERATED ALWAYS AS ROW START,
ValidTo DATETIME2 GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo)
)
WITH
(
SYSTEM_VERSIONING = ON
);

Querying Historical Data

SQL provides temporal query options.

Example:

SELECT *
FROM Employees
FOR SYSTEM_TIME AS OF '2025-01-01';

This retrieves the table exactly as it existed at the specified point in time.

Other options include:

  • FROM…TO
  • BETWEEN
  • CONTAINED IN
  • ALL

Benefits

Temporal tables provide:

  • Automatic history
  • Point-in-time recovery
  • Audit support
  • Trend analysis
  • Easier reporting

Typical Use Cases

Examples include:

  • Employee history
  • Customer profile changes
  • Insurance records
  • Compliance reporting
  • AI training using historical snapshots

External Tables

What Are External Tables?

External tables allow SQL Server or Azure SQL to query data stored outside the database without importing it.

The external data remains in its original location.

SQL accesses it through metadata.


Supported Data Sources

External tables can access:

  • Azure Data Lake Storage
  • Azure Blob Storage
  • Hadoop
  • Microsoft Fabric OneLake
  • SQL Server
  • Oracle (through supported virtualization technologies)
  • Parquet files
  • CSV files
  • Delta Lake (supported platforms)

PolyBase

SQL Server commonly uses PolyBase to query external data.

PolyBase allows T-SQL queries against external sources.

Example architecture:

SQL Server
External Table
Azure Data Lake

Advantages

Benefits include:

  • No data duplication
  • Large-scale analytics
  • Access data lakes
  • Simplified ETL
  • Lower storage costs

Common AI Scenarios

AI projects frequently use external tables to access:

  • Training datasets
  • Data lake files
  • Feature engineering data
  • Parquet datasets
  • Fabric Lakehouse data

Considerations

Performance depends on:

  • Network speed
  • External storage
  • Predicate pushdown
  • File formats
  • Data partitioning

Ledger Tables

What Are Ledger Tables?

Ledger tables provide tamper-evident records.

They use cryptographic hashing to detect unauthorized modifications.

Ledger technology helps organizations prove that data has not been altered.


Why Ledger Tables Matter

Industries with regulatory requirements often require immutable records.

Examples include:

  • Banking
  • Healthcare
  • Government
  • Supply chain
  • Legal systems

How They Work

Ledger tables automatically maintain:

  • Transaction history
  • Cryptographic digests
  • Verification metadata

Attempts to modify historical records become detectable.


Updatable Ledger Tables

These support:

  • INSERT
  • UPDATE
  • DELETE

While preserving historical versions.


Append-Only Ledger Tables

These allow:

  • INSERT

Only.

Rows cannot be updated or deleted.

Useful for:

  • Financial journals
  • Event logs
  • Blockchain-style records

Benefits

Ledger tables provide:

  • Data integrity
  • Nonrepudiation
  • Tamper evidence
  • Simplified auditing
  • Regulatory compliance

Typical Use Cases

Examples include:

  • Financial transactions
  • Audit logs
  • Medical records
  • Government systems
  • Digital contracts

Graph Tables

What Are Graph Tables?

Graph tables model relationships between entities.

Instead of relying solely on foreign keys, graph databases represent information as:

  • Nodes
  • Edges

This structure is ideal for highly connected data.


Node Tables

Node tables store entities.

Examples:

  • Customers
  • Products
  • Employees
  • Devices
  • Companies

Example:

CREATE TABLE Person
(
ID INT,
Name NVARCHAR(100)
)
AS NODE;

Edge Tables

Edge tables define relationships.

Example:

CREATE TABLE FriendOf
AS EDGE;

Possible relationships:

  • Friend of
  • Purchased
  • Works for
  • Located in
  • Connected to

Graph Queries

Graph queries use the MATCH clause.

Example:

SELECT *
FROM Person,
FriendOf,
Person
WHERE MATCH(Person-(FriendOf)->Person);

Advantages

Graph tables simplify:

  • Relationship traversal
  • Network analysis
  • Recommendation systems
  • Fraud detection
  • Organizational charts

AI Use Cases

Graph tables are increasingly valuable for AI because they model relationships that traditional relational databases handle less efficiently.

Examples include:

  • Knowledge graphs
  • Recommendation engines
  • Customer relationship analysis
  • Social networks
  • Supply chain analysis
  • Fraud detection

Choosing the Correct Specialized Table

RequirementBest Choice
Maximum OLTP performanceIn-Memory Table
Automatic historyTemporal Table
Access data lakeExternal Table
Tamper-evident recordsLedger Table
Relationship analysisGraph Table

Comparing Specialized Tables

FeatureIn-MemoryTemporalExternalLedgerGraph
High-speed transactions
Historical tracking
External data
Tamper detection
Relationship modeling
AI training support

Best Practices

In-Memory Tables

  • Use for high-volume OLTP workloads.
  • Choose an appropriate bucket count for hash indexes.
  • Monitor memory consumption carefully.
  • Use SCHEMA_AND_DATA for durable business data.

Temporal Tables

  • Use for audit and historical reporting.
  • Periodically archive large history tables if appropriate.
  • Query historical versions using FOR SYSTEM_TIME.

External Tables

  • Prefer efficient file formats such as Parquet.
  • Partition large datasets.
  • Minimize unnecessary data movement.
  • Push filtering to the external source whenever possible.

Ledger Tables

  • Use when regulatory compliance or auditability is required.
  • Understand the difference between append-only and updatable ledger tables.
  • Regularly verify ledger digests as part of governance processes.

Graph Tables

  • Use when relationships are central to the data model.
  • Avoid replacing well-designed relational models unnecessarily.
  • Combine graph and relational tables where appropriate.

Common Exam Tips

For the DP-800 exam, remember these important distinctions:

  • In-memory tables improve OLTP performance through memory optimization and optimistic concurrency.
  • Temporal tables automatically maintain historical versions of data using system versioning.
  • External tables allow SQL queries against data stored outside the database without importing it.
  • Ledger tables provide cryptographically verifiable, tamper-evident records for auditing and compliance.
  • Graph tables represent entities and relationships using node and edge tables and support graph pattern matching with the MATCH clause.
  • SCHEMA_ONLY memory-optimized tables do not preserve data after a restart, while SCHEMA_AND_DATA tables do.
  • Append-only ledger tables support inserts only; updatable ledger tables support inserts, updates, and deletes while preserving history.

Practice Exam Questions

Question 1

A financial trading application requires extremely high transaction throughput while minimizing locking and blocking. Which table type should be implemented?

A. Temporal table

B. In-memory table

C. Ledger table

D. External table

Answer: B

Explanation: In-memory tables use memory-optimized storage and lock-free, latch-free processing to maximize OLTP performance and concurrency.


Question 2

A company wants SQL Server to automatically maintain historical versions of customer records whenever updates occur. Which feature should be used?

A. External table

B. Graph table

C. Temporal table

D. Ledger table

Answer: C

Explanation: Temporal tables automatically maintain current and historical versions of rows using system versioning, eliminating the need for custom audit triggers.


Question 3

A database administrator needs to query Parquet files stored in Azure Data Lake without copying the data into SQL Server. Which table type is most appropriate?

A. External table

B. Ledger table

C. In-memory table

D. Temporal table

Answer: A

Explanation: External tables provide metadata that enables SQL queries against external data sources such as Azure Data Lake and Parquet files without importing the data.


Question 4

Which specialized table type provides cryptographic verification that historical records have not been altered?

A. Graph table

B. External table

C. Temporal table

D. Ledger table

Answer: D

Explanation: Ledger tables use cryptographic hashing and transaction digests to create tamper-evident records suitable for auditing and regulatory compliance.


Question 5

Which statement about memory-optimized tables configured with SCHEMA_ONLY durability is correct?

A. Both schema and data survive a server restart.

B. The table cannot contain indexes.

C. The table definition remains, but the data is lost after a restart.

D. The table is automatically converted to a temporal table.

Answer: C

Explanation: SCHEMA_ONLY durability preserves only the table definition. Data stored in the table is not retained after the SQL Server instance restarts.


Question 6

Which SQL Server feature is specifically designed to model entities and their relationships using node and edge tables?

A. Ledger

B. PolyBase

C. Temporal

D. Graph

Answer: D

Explanation: Graph tables use node and edge tables to represent entities and relationships and support graph pattern matching using the MATCH clause.


Question 7

A retail company wants to analyze historical pricing information exactly as it existed on a specific date six months ago. Which query capability supports this requirement?

A. MATCH

B. FOR SYSTEM_TIME AS OF

C. OPENROWSET

D. MERGE

Answer: B

Explanation: The FOR SYSTEM_TIME AS OF clause queries a temporal table as it existed at a specified point in time.


Question 8

Which workload is the best candidate for a clustered in-memory table?

A. A data warehouse containing historical sales data

B. A compliance audit archive

C. A product catalog that rarely changes

D. A high-volume online order processing system

Answer: D

Explanation: In-memory tables are designed for OLTP workloads with frequent inserts, updates, and concurrent transactions.


Question 9

What is the primary advantage of using external tables in AI-enabled database solutions?

A. They automatically encrypt all external files.

B. They eliminate the need for indexes.

C. They enable SQL queries against externally stored datasets without duplicating the data.

D. They automatically convert relational data into graph structures.

Answer: C

Explanation: External tables allow SQL Server and Azure SQL to access external data sources directly, making them ideal for AI workloads that consume large datasets stored in data lakes.


Question 10

Which scenario is the best fit for an append-only ledger table?

A. A customer profile database requiring frequent updates

B. A temporary ETL staging table

C. A social network relationship graph

D. A financial transaction journal where records must never be modified or deleted

Answer: D

Explanation: Append-only ledger tables permit inserts but prevent updates and deletes, making them ideal for immutable transaction logs and regulatory audit records.


Go to the DP-800 Exam Prep Hub main page

Describe Types of Databases (DP-900 Exam Prep)

This post is a part of the DP-900: Microsoft Azure Data Fundamentals Exam Prep Hub. 
This topic falls under these sections:
Describe core data concepts (25–30%)
--> Identify options for data storage
--> Describe types of databases


Note that there are 10 practice questions (with answers and explanations) for each section to help you solidify your knowledge of the material. Also, there are 2 practice tests with 60 questions each available on the hub below the exam topics section.

Databases are systems that store and manage data so applications can retrieve, update, and organize it efficiently. For DP-900, you should be familiar with the major types of databases, how they differ, and common use cases — especially in relation to Azure services.


What Is a Database?

A database is an organized collection of data that enables efficient access, management, and update of information. Databases may differ in how they model, structure, and query data depending on the data type, scale, and workload requirements.


Primary Types of Databases

At a high level, databases fall into two broad categories:

  1. Relational Databases
  2. Non-Relational Databases (NoSQL)

1. Relational Databases

Relational databases (RDBMS) store data in tables with rows and columns.

Key Features

  • Structured schema: Tables have defined columns with data types.
  • Relationships: Tables can be linked using keys (e.g., primary and foreign keys).
  • SQL Queries: Use Structured Query Language (SQL) to retrieve and manipulate data.
  • ACID transactions: Support atomicity, consistency, isolation, and durability for reliable data operations.

When to Use

  • Applications requiring strong data integrity
  • Banking, accounting, inventory systems
  • Workloads where relationships among data matter

Examples

  • Azure SQL Database
  • Azure Database for PostgreSQL
  • Azure Database for MySQL

2. Non-Relational Databases (NoSQL)

Non-relational databases, often called NoSQL databases, store data in ways that differ from traditional tables. They are generally schema-less and more flexible, which helps with scalability and handling varied data types.

Key Characteristics

  • No fixed schema
  • Designed for horizontal scaling and large data volumes
  • Support for semi-structured and unstructured data
  • Often optimized for specific access patterns

The most common NoSQL models include:


a. Key-Value Databases

Key-value stores are the simplest type of NoSQL database.

  • Data stored as pairs: key (identifier) and value (data).
  • Efficient for simple lookups when the key is known.

Use cases: Session state, caching, user preferences.


b. Document Databases

Document databases store data as documents, typically in JSON format.

  • Each document is a self-describing object with a unique ID.
  • Supports nested fields and flexible attributes.

Use cases: Content management, user profiles, web apps.


c. Column-Family (Wide-Column) Databases

Column-family databases use tables with column families — groups of related columns that can vary by row.

  • Designed for wide tables where columns are sparse.
  • Good for distributed data and analytical workloads.

Use cases: Time-series data, analytics, event logging.


d. Graph Databases

Graph databases focus on relationships between data elements.

  • Use nodes (entities) and edges (relationships).
  • Optimized for queries involving deep connections (e.g., social networks).

Use cases: Recommendation engines, fraud detection, network analysis.


Relational vs Non-Relational: A Quick Comparison

FeatureRelationalNon-Relational (NoSQL)
SchemaFixedFlexible / Schema-less
Data ModelTablesVaries (documents, keys, graphs)
Query LanguageSQLVaries by database
ScalabilityVertical scalingHorizontal scaling
Typical UseStrong consistency & relationshipsLarge, evolving, semi/unstructured data

How Azure Supports These Databases

Relational Database Services

Azure provides managed relational services:

  • Azure SQL Database: Managed SQL service
  • Azure Database for MySQL and PostgreSQL: Managed open-source options

These are ideal for structured data and transactional workloads.


Non-Relational Database Services

Azure supports NoSQL and other flexible databases:

  • Azure Cosmos DB: A globally distributed, multi-model NoSQL database service that supports document, key-value, column-family, and graph models.

This makes Cosmos DB unique in supporting multiple non-relational data models from a single service.


Why Understanding Types of Databases Matters for DP-900

On the DP-900 exam, you may be asked to:

  • Classify a database type based on a description of its structure.
  • Choose the best database model for a given business scenario.
  • Identify Azure services that match a database type.

Knowing relational vs non-relational databases, and the sub-types of NoSQL models, will help you answer these questions with confidence.


Summary — Exam-Relevant Takeaways

Relational databases store structured data using tables, enforce schemas, and use SQL.
NoSQL databases store non-relational data and include key-value, document, column-family, and graph types.
Azure SQL Database and open-source relational offerings support structured workloads.
Azure Cosmos DB supports multiple non-relational models for schema-flexible data.


Go to the Practice Exam Questions for this topic.

Go to the DP-900 Exam Prep Hub main page.

Practice Questions: Describe Types of Databases (DP-900 Exam Prep)

Practice Questions


Question 1

You need to store customer orders in tables with fixed columns and enforce relationships between customers and orders.

Which type of database should you use?

A. Graph
B. Document
C. Relational
D. Key-value

Answer: C

Explanation:
Relational databases store structured data in tables with defined schemas and support relationships via keys.


Question 2

Which characteristic best describes a relational database?

A. Schema-less storage
B. Data stored as JSON documents
C. Tables with rows and columns
D. Nodes and edges

Answer: C

Explanation:
Relational databases organize data into tables (rows and columns) and use SQL for querying.


Question 3

An application must store user profiles in flexible JSON documents where each user may have different attributes.

Which database type is most appropriate?

A. Column-family
B. Document
C. Relational
D. Graph

Answer: B

Explanation:
Document databases store data as JSON-like documents and allow flexible schemas — ideal for user profiles.


Question 4

Which Azure service supports multiple NoSQL data models such as Core (SQL) API, Table API, Cassandra API, and Gremlin API?

A. Azure SQL Database
B. Azure Table Storage
C. Azure Cosmos DB
D. Azure Database for PostgreSQL

Answer: C

Explanation:
Azure Cosmos DB is a globally distributed, multi-model NoSQL database service.


Question 5

You are designing a recommendation engine that analyzes relationships between users and products.

Which database type is best suited?

A. Relational
B. Key-value
C. Graph
D. Column-family

Answer: C

Explanation:
Graph databases specialize in relationship-heavy data using nodes and edges.


Question 6

Which statement about NoSQL databases is TRUE?

A. They always require fixed schemas
B. They primarily use SQL
C. They are optimized for horizontal scaling
D. They cannot store structured data

Answer: C

Explanation:
NoSQL databases are designed for horizontal scaling and flexible schemas.


Question 7

You need extremely fast lookups using a unique identifier, and the data structure is simple.

Which NoSQL model should you choose?

A. Document
B. Graph
C. Column-family
D. Key-value

Answer: D

Explanation:
Key-value databases store data as key/value pairs and provide very fast retrieval.


Question 8

Which Azure service is best suited for structured transactional workloads using SQL?

A. Azure Blob Storage
B. Azure Cosmos DB
C. Azure SQL Database
D. Azure Data Lake Storage

Answer: C

Explanation:
Azure SQL Database is a managed relational database service optimized for structured transactional data.


Question 9

Which feature is typically associated with relational databases but not guaranteed in NoSQL systems?

A. Global distribution
B. Flexible schemas
C. ACID transactions
D. Horizontal scaling

Answer: C

Explanation:
Relational databases traditionally provide full ACID transaction support.


Question 10

A company collects massive volumes of time-series telemetry data where columns may vary across rows.

Which database type fits this scenario best?

A. Relational
B. Document
C. Column-family
D. Graph

Answer: C

Explanation:
Column-family (wide-column) databases are well suited for large, sparse datasets such as time-series data.


✅ Key Exam Reminders

For DP-900, make sure you can confidently:

  • Distinguish relational vs non-relational
  • Recognize NoSQL models (key-value, document, column-family, graph)
  • Match Azure services to database types (especially Azure SQL vs Azure Cosmos DB)
  • Choose the right database type for a scenario

Go to the DP-900 Exam Prep Hub main page.