Tag: Database objects

Expose database objects, stored procedures, and views, including GraphQL relationships (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:
Secure, optimize, and deploy database solutions (35–40%)
   --> Integrate SQL solutions with Azure services
      --> Expose database objects, stored procedures, and views, including GraphQL relationships


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 applications rarely communicate directly with a database. Instead, they interact with APIs that expose only the data and operations that applications require. Microsoft’s Data API builder (DAB) provides a secure and efficient way to expose Azure SQL Database, Azure SQL Managed Instance, SQL Server, and Azure Database for PostgreSQL as REST and GraphQL APIs without requiring developers to build custom API services.

One of the primary responsibilities of a SQL AI Developer is deciding which database objects should be exposed, how they should be exposed, and how relationships between entities should be represented, particularly in GraphQL.

For the DP-800 exam, candidates should understand how to expose:

  • Tables
  • Views
  • Stored procedures
  • Relationships between entities
  • GraphQL navigation
  • REST resources
  • Security considerations
  • Performance considerations

Why Expose Database Objects?

Instead of allowing applications to connect directly to a database, organizations commonly expose selected database objects through APIs because APIs provide:

  • Better security
  • Controlled access
  • Versioning
  • Authentication
  • Authorization
  • Business logic abstraction
  • Simplified client development

Rather than allowing direct SQL access, applications interact with HTTP endpoints such as:

GET /api/Products

or GraphQL queries like:

query {
products {
ProductID
Name
Price
}
}

Objects That Can Be Exposed

Microsoft Data API builder can expose several database object types.

1. Tables

Tables are the most common objects exposed.

Example:

Products
Customers
Orders
Employees

Each table becomes an entity.

Example DAB configuration:

{
"entities": {
"Products": {
"source": "Products"
}
}
}

REST endpoints generated:

GET /api/Products
POST /api/Products
PATCH /api/Products
DELETE /api/Products

GraphQL automatically generates:

products
product_by_pk

and corresponding mutations.


2. Views

Views provide a secure way to expose pre-filtered or joined data.

Example:

vwSalesSummary

Instead of exposing many tables, clients consume the view.

Benefits include:

  • Simplified queries
  • Hidden table structure
  • Security abstraction
  • Read-only reporting

Example:

CustomerName
OrderCount
TotalSales

instead of requiring joins.

Views are especially useful for reporting applications.


3. Stored Procedures

Stored procedures expose business logic rather than raw tables.

Example:

EXEC usp_CreateOrder

Instead of allowing clients to insert rows manually.

Advantages include:

  • Validation
  • Business rules
  • Transactions
  • Consistent processing

Data API builder supports stored procedures as API operations.

Example REST endpoint:

POST /api/CreateOrder

Why Use Stored Procedures?

Stored procedures provide:

  • Better security
  • Centralized business rules
  • Reduced network traffic
  • Transaction handling
  • Parameter validation

Example:

Instead of:

Insert Order
Insert Items
Update Inventory
Calculate Discount
Commit Transaction

The application calls:

CreateOrder()

The stored procedure performs every operation safely.


Exposing Views vs Tables

TablesViews
Raw dataProcessed data
Often updateableOften read-only
Complete schemaSimplified schema
Less abstractionGreater abstraction
Better for CRUDBetter for reporting

Exposing Stored Procedures

Stored procedures typically become REST POST operations because they execute actions.

Example:

POST
/api/ProcessPayment

Input:

{
"OrderID":1054
}

The procedure performs the transaction.


GraphQL Relationships

One of GraphQL’s greatest advantages is navigating relationships between entities.

Instead of making several REST calls:

Customers
Orders
OrderDetails

GraphQL can retrieve all related information in one request.

Example:

query {
customers {
CustomerName
orders {
OrderID
OrderDate
orderDetails {
ProductName
Quantity
}
}
}

GraphQL traverses relationships automatically.


Understanding Relationships

Suppose the database contains:

Customers
Orders
Products
OrderDetails

Relationships:

Customer
|
| 1:M
|
Orders
|
| 1:M
|
OrderDetails
|
| M:1
|
Products

GraphQL follows these relationships naturally.


One-to-Many Relationships

Example:

Customer

↓

Orders

Example query:

query{
customers{
CustomerName
orders{
OrderID
OrderDate
}
}
}

The response includes each customer’s orders.


Many-to-One Relationships

Example:

OrderDetails

↓

Product

query{
orderDetails{
Quantity
product{
Name
Price
}
}
}

Many-to-Many Relationships

Many-to-many relationships are typically implemented through junction tables.

Example:

Students
Courses
StudentCourses

GraphQL can expose navigation through the junction table.


REST vs GraphQL for Relationships

REST

GET Customers
GET Orders
GET OrderDetails

Multiple requests required.

GraphQL

One query retrieves everything.

Advantages:

  • Reduced network traffic
  • Less over-fetching
  • Less under-fetching
  • Better performance

Relationship Configuration in Data API Builder

Relationships are defined inside the configuration.

Example concept:

Customers
hasMany
Orders

and

Orders
belongsTo
Customers

This allows nested GraphQL queries.


CRUD Support

Depending on configuration, exposed entities may support:

Create

POST

Read

GET

Update

PUT
PATCH

Delete

DELETE

Not every entity must support every operation.

For example:

Views

Read Only

Tables

Read + Write

Restricting Exposed Objects

Best practice is not to expose every table.

Expose only:

  • Required tables
  • Required views
  • Required procedures

Avoid exposing:

  • Audit tables
  • Internal configuration
  • Security tables
  • Temporary tables
  • Logging tables

Least privilege always applies.


Security Considerations

When exposing database objects:

  • Require HTTPS
  • Use Microsoft Entra authentication
  • Apply least privilege
  • Use role-based authorization
  • Expose only necessary objects
  • Validate procedure parameters
  • Avoid exposing sensitive columns
  • Audit endpoint usage

Performance Considerations

Good API design includes:

  • Return only needed fields
  • Use pagination
  • Cache reference data
  • Optimize SQL queries
  • Index frequently queried columns
  • Avoid unnecessary nested GraphQL queries
  • Use views for complex reporting

Common DP-800 Exam Tips

Know when to expose:

ObjectTypical Use
TableCRUD operations
ViewReporting and simplified queries
Stored ProcedureBusiness logic and transactions
GraphQL RelationshipNested related data
REST EndpointResource-oriented operations

Summary

For the DP-800 exam, you should understand that Data API builder can expose tables, views, and stored procedures as secure REST and GraphQL endpoints. Tables are commonly used for CRUD operations, views simplify reporting and hide underlying schemas, and stored procedures encapsulate business logic and transactional operations. GraphQL relationships allow clients to traverse related entities in a single request, reducing network calls and simplifying application development. Developers should expose only the objects required by the application, apply least-privilege security principles, and optimize endpoints for performance and maintainability.


Practice Exam Questions

Question 1

Your organization wants external applications to retrieve product information without exposing the underlying table structure or requiring complex joins. Which database object should you expose?

A. A view

B. A database trigger

C. A SQL Agent job

D. A temporary table

Correct Answer:

A. A view

Explanation

Views present a simplified, controlled representation of data by encapsulating joins and filters. They hide the underlying schema, making them ideal for reporting and read-only access. Triggers, SQL Agent jobs, and temporary tables are not intended to expose data to applications.


Question 2

Which type of database object is best suited for encapsulating business logic that performs multiple database operations within a single transaction?

A. A view

B. A stored procedure

C. A synonym

D. An index

Correct Answer:

B. A stored procedure

Explanation

Stored procedures centralize business logic, validate inputs, manage transactions, and execute multiple SQL statements as a single unit of work. Views are primarily for querying data, while synonyms and indexes do not execute business logic.


Question 3

An application uses GraphQL to retrieve customer information and all associated orders in a single request.

Which GraphQL capability makes this possible?

A. Automatic indexing

B. HTTP caching

C. Entity relationships

D. SQL triggers

Correct Answer:

C. Entity relationships

Explanation

GraphQL relationships allow clients to traverse related entities through nested queries, enabling retrieval of customers and their orders in a single request. This is one of GraphQL’s primary advantages over traditional REST APIs.


Question 4

A developer exposes a database table through Data API builder and wants clients to retrieve records using REST.

Which HTTP method should clients use?

A. DELETE

B. PATCH

C. POST

D. GET

Correct Answer:

D. GET

Explanation

REST uses the GET method to retrieve resources. POST creates resources, PATCH updates existing resources, and DELETE removes resources.


Question 5

Which object is most appropriate for exposing aggregated sales totals without allowing users to modify the underlying data?

A. A stored procedure

B. A table

C. A view

D. A trigger

Correct Answer:

C. A view

Explanation

Views are commonly used to expose aggregated or summarized information while hiding the complexity of the underlying tables. Many reporting views are read-only, preventing accidental modifications.


Question 6

A Data API builder configuration includes only the Products and Categories entities.

What happens if a client attempts to access the Employees table?

A. The request succeeds because all tables are exposed automatically.

B. The table is exposed only through GraphQL.

C. The request fails because Employees is not configured as an exposed entity.

D. Data API builder creates the endpoint automatically.

Correct Answer:

C. The request fails because Employees is not configured as an exposed entity.

Explanation

Data API builder exposes only the entities explicitly defined in its configuration. Objects not configured remain inaccessible through both REST and GraphQL endpoints.


Question 7

Why should developers avoid exposing every database table through REST or GraphQL endpoints?

A. Because GraphQL cannot access multiple tables.

B. To follow the principle of least privilege and reduce security risks.

C. Because Data API builder supports only five entities.

D. To improve SQL syntax compatibility.

Correct Answer:

B. To follow the principle of least privilege and reduce security risks.

Explanation

Exposing only required objects reduces the attack surface, protects sensitive data, and aligns with security best practices. Internal, audit, configuration, and security tables should generally remain inaccessible.


Question 8

Which GraphQL feature reduces the need for multiple REST API calls when retrieving related data?

A. Stored procedures

B. Pagination

C. HTTP status codes

D. Nested queries using relationships

Correct Answer:

D. Nested queries using relationships

Explanation

GraphQL allows nested queries that follow entity relationships, enabling clients to retrieve related objects in a single request. This minimizes network traffic and simplifies application development.


Question 9

Which database object is generally the best choice for exposing an operation that validates inventory, creates an order, updates stock levels, and commits the transaction?

A. A stored procedure

B. A view

C. A nonclustered index

D. A foreign key

Correct Answer:

A. A stored procedure

Explanation

Stored procedures encapsulate complex business processes, ensure transactional consistency, and centralize business rules. Views and indexes cannot perform transactional workflows.


Question 10

A GraphQL query retrieves customer information along with orders and order details.

What is the primary benefit of this approach compared to making several REST requests?

A. SQL Server automatically creates indexes.

B. Database permissions are no longer required.

C. Authentication becomes optional.

D. Multiple related resources can be retrieved in a single request, reducing network overhead.

Correct Answer:

D. Multiple related resources can be retrieved in a single request, reducing network overhead.

Explanation

GraphQL enables clients to retrieve exactly the required data—including related entities—in a single query. This reduces round trips, minimizes over-fetching and under-fetching, and often improves application performance.


Go to the DP-800 Exam Prep Hub main page

Design and implement tables, including data types, size, columns, indexes, and column store 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 tables, including data types, size, columns, indexes, and column store 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

One of the most fundamental skills measured on the DP-800: Developing AI-Enabled Database Solutions exam is the ability to design and implement efficient database tables. Every SQL solution—whether supporting traditional applications, analytics, or AI-enabled workloads—depends on well-designed tables that maximize performance, maintain data integrity, minimize storage requirements, and scale effectively.

Poor table design often results in slow queries, excessive storage consumption, locking issues, and difficult maintenance. Conversely, properly designed tables improve application responsiveness, simplify development, and reduce infrastructure costs.

This article covers the key concepts required for the DP-800 exam, including:

  • Choosing appropriate data types
  • Determining column sizes
  • Designing table structures
  • Creating clustered and nonclustered indexes
  • Understanding filtered, included, and composite indexes
  • Implementing columnstore indexes
  • Best practices and common design mistakes

Designing Tables

A table stores related information organized into rows and columns.

Good table design should achieve the following goals:

  • Eliminate unnecessary duplication
  • Support efficient queries
  • Enforce data integrity
  • Reduce storage requirements
  • Support future growth
  • Minimize maintenance

A typical design process includes:

  1. Identify entities
  2. Define columns
  3. Choose data types
  4. Select appropriate sizes
  5. Determine nullable columns
  6. Define primary keys
  7. Create foreign keys
  8. Add indexes based on workload

Choosing Appropriate Data Types

Selecting the correct data type is one of the most important database design decisions.

Using oversized or inappropriate data types increases:

  • Storage usage
  • Memory usage
  • Network traffic
  • Index size
  • Backup size
  • Query execution time

Integer Data Types

Data TypeStorageRange
TINYINT1 byte0–255
SMALLINT2 bytes-32,768 to 32,767
INT4 bytes±2.1 billion
BIGINT8 bytesExtremely large values

Example:

CustomerID INT
OrderID BIGINT
Age TINYINT

CustomerID INT

OrderID BIGINT

Age TINYINT




Decimal and Numeric

Used for precise financial calculations.

Price DECIMAL(10,2)

Price DECIMAL(10,2)



  • 10 total digits
  • 2 digits after the decimal

Examples:

12345678.90
99999999.99

12345678.90
99999999.99<b
r>


</b


Floating Point Types

Used for scientific calculations.

FLOAT
REAL

FLOAT



REAL

  • Measurements
  • Statistics
  • Sensor data

Avoid for:

  • Currency
  • Accounting
  • Financial systems

Character Data Types

CHAR

Fixed-length storage.

CHAR(2)

CHAR(2)



  • Country codes
  • State abbreviations
  • Status values

VARCHAR

Variable-length storage.

VARCHAR(100)

VARCHAR(100)



Ideal for:

  • Names
  • Email addresses
  • Descriptions

NCHAR and NVARCHAR

Support Unicode characters.

NVARCHAR(100)

NVARCHAR(100)



  • Multiple languages
  • International names
  • Emoji
  • Unicode symbols

VARCHAR(MAX)

Stores very large text.

Use only when necessary.

Examples:

  • Documents
  • Long descriptions
  • JSON

Avoid using MAX columns unnecessarily because they reduce performance.


Date and Time Data Types

Common options include:

TypeDescription
DATEDate only
TIMETime only
DATETIME2Date and time with high precision
DATETIMEOFFSETDate/time plus time zone

Microsoft recommends DATETIME2 for most new applications.

Example:

CreatedDate DATETIME2

Binary Data Types

Examples include:

VARBINARY
VARBINARY(MAX)

VARBINARY



VARBINARY(MAX)

  • Images
  • Encryption keys
  • Files
  • AI embeddings (in some scenarios)

UniqueIdentifier

Stores globally unique identifiers (GUIDs).

CustomerGuid UNIQUEIDENTIFIER

CustomerGuid UNIQUEIDENTIFIER



  • Globally unique
  • Useful for distributed systems

Drawbacks:

  • Larger indexes
  • Can fragment clustered indexes when generated randomly

NULL vs NOT NULL

Every column should explicitly define whether NULL values are allowed.

Example:

FirstName NVARCHAR(50) NOT NULL
MiddleName NVARCHAR(50) NULL

FirstName NVARCHAR(50) NOT NULL

MiddleName NVARCHAR(50) NULL



  • Improves data integrity
  • Simplifies queries
  • Often improves performance

Identity Columns

Automatically generate sequential values.

Example:

CustomerID INT IDENTITY(1,1)

CustomerID INT IDENTITY(1,1)



Start at 1

Increment by 1

Commonly used as surrogate primary keys.


Computed Columns

Values calculated from other columns.

Example:

FullName AS FirstName + ' ' + LastName

FullName AS FirstName + ‘ ‘ + LastName




Sparse Columns

Designed for tables with many NULL values.

Benefits:

  • Reduce storage
  • Useful for optional attributes

Trade-off:

Slightly higher processing overhead.


Table Constraints

Constraints enforce data integrity.

Primary Key

Uniquely identifies each row.

PRIMARY KEY (CustomerID)

PRIMARY KEY (CustomerID)



  • Unique
  • NOT NULL
  • Automatically indexed

Foreign Key

Maintains relationships between tables.

FOREIGN KEY (CustomerID)
REFERENCES Customers(CustomerID)

UNIQUE Constraint

Prevents duplicate values.

Example:

EmailAddress UNIQUE

CHECK Constraint

Restricts acceptable values.

Example:

CHECK (Salary > 0)

DEFAULT Constraint

Automatically inserts default values.

Example:

CreatedDate DATETIME2
DEFAULT GETDATE()

Index Fundamentals

Indexes improve query performance by reducing table scans.

Without indexes:

SQL Server reads every row.

SQL Server reads every row.



SQL Server quickly locates matching rows.

SQL Server quickly locates matching rows.



  • WHERE
  • JOIN
  • ORDER BY
  • GROUP BY

Clustered Index

Determines the physical order of rows.

Each table can have only one clustered index.

Example:

CREATE CLUSTERED INDEX IX_Customers
ON Customers(CustomerID);

CREATE CLUSTERED INDEX IX_Customers

ON Customers(CustomerID);



  • Primary keys
  • Sequential values

Nonclustered Index

Stores a separate searchable structure.

A table can have many nonclustered indexes.

Example:

CREATE INDEX IX_LastName
ON Customers(LastName);

CREATE INDEX IX_LastName

ON Customers(LastName);




Composite Index

Contains multiple columns.

Example:

CREATE INDEX IX_OrderDateCustomer
ON Orders(OrderDate, CustomerID);

CREATE INDEX IX_OrderDateCustomer

ON Orders(OrderDate, CustomerID);



The leftmost column should be the most selective or frequently filtered.


Included Columns

Include non-key columns to create covering indexes.

Example:

CREATE INDEX IX_LastName
ON Customers(LastName)
INCLUDE (FirstName, EmailAddress);

CREATE INDEX IX_LastName

ON Customers(LastName)

INCLUDE (FirstName, EmailAddress);



  • Reduces key lookups
  • Improves SELECT performance

Filtered Index

Indexes only selected rows.

Example:

CREATE INDEX IX_ActiveCustomers
ON Customers(Status)
WHERE Status='Active';

CREATE INDEX IX_ActiveCustomers

ON Customers(Status)



WHERE Status=’Active’;

  • Smaller index
  • Faster maintenance
  • Better query performance

Covering Index

A covering index contains every column required by a query.

Example:

Query:

SELECT FirstName, LastName
FROM Customers
WHERE LastName='Smith';

SELECT FirstName, LastName

FROM Customers

WHERE LastName=’Smith’;



  • LastName (key)
  • FirstName (included)

No lookup to the base table is required.


Index Maintenance

Indexes require regular maintenance.

Common tasks include:

  • Rebuild indexes
  • Reorganize indexes
  • Update statistics
  • Monitor fragmentation

Highly fragmented indexes reduce performance.


Columnstore Indexes

Columnstore indexes store data by columns rather than rows.

Traditional storage:

Row 1
Row 2
Row 3

Row 1

Row 2

Row 3



CustomerID
FirstName
LastName
City

CustomerID

FirstName

LastName

City




Benefits of Columnstore Indexes

Advantages include:

  • High compression
  • Reduced storage
  • Faster aggregations
  • Parallel processing
  • Batch execution mode

Ideal for:

  • Data warehouses
  • Reporting
  • Analytics
  • AI feature engineering
  • Large fact tables

Clustered Columnstore Index

Entire table stored in column format.

Example:

CREATE CLUSTERED COLUMNSTORE INDEX CCI_Sales
ON Sales;

CREATE CLUSTERED COLUMNSTORE INDEX CCI_Sales

ON Sales;



  • Fact tables
  • Large analytical workloads

Nonclustered Columnstore Index

Adds columnstore capabilities to an existing rowstore table.

Example:

CREATE NONCLUSTERED COLUMNSTORE INDEX NCCI_Sales
ON Sales
(
Revenue,
Quantity,
ProductID
);

CREATE NONCLUSTERED COLUMNSTORE INDEX NCCI_Sales

ON Sales


(
Reven
ue,
Quantity,

ProductID

);




Rowstore vs Columnstore

FeatureRowstoreColumnstore
Best forOLTPAnalytics
InsertsExcellentGood
UpdatesExcellentModerate
AggregationsModerateExcellent
CompressionLowVery High
Large scansSlowerMuch Faster

Choosing the Right Index

ScenarioRecommended Index
Primary keyClustered
Frequent lookupsNonclustered
Multi-column searchesComposite
ReportingColumnstore
Active records onlyFiltered
Covering queriesIncluded columns

Best Practices

  • Choose the smallest appropriate data type.
  • Avoid VARCHAR(MAX) unless required.
  • Use DATETIME2 instead of DATETIME for new development.
  • Define NOT NULL whenever appropriate.
  • Create indexes based on query patterns rather than every column.
  • Avoid excessive indexing because each index increases insert, update, and delete costs.
  • Use composite indexes carefully, considering column order.
  • Regularly rebuild or reorganize fragmented indexes.
  • Use clustered columnstore indexes for large analytical tables.
  • Test index changes using execution plans and performance metrics.

Common Exam Tips

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

  • Smaller data types improve storage efficiency.
  • Clustered indexes determine physical row order.
  • A table can have only one clustered index.
  • Multiple nonclustered indexes are allowed.
  • Included columns create covering indexes.
  • Filtered indexes reduce storage and improve performance for selective queries.
  • Composite index column order matters.
  • Columnstore indexes are optimized for analytical workloads.
  • DATETIME2 is preferred over DATETIME for new applications.
  • FLOAT should not be used for financial data.

Practice Exam Questions

Question 1

A database designer needs to store a person’s age. The maximum expected value is 120. Which data type is the most storage-efficient?

A. INT

B. SMALLINT

C. TINYINT

D. BIGINT

Answer: C

Explanation: TINYINT stores values from 0 to 255 using only one byte, making it the most efficient choice for age values.


Question 2

A company stores customer names in multiple languages, including Japanese and Arabic. Which data type should be used?

A. CHAR

B. VARCHAR

C. TEXT

D. NVARCHAR

Answer: D

Explanation: NVARCHAR supports Unicode characters, making it suitable for multilingual applications.


Question 3

Which index determines the physical order of rows within a SQL Server table?

A. Nonclustered index

B. Filtered index

C. Clustered index

D. Columnstore index

Answer: C

Explanation: A clustered index defines the physical storage order of rows. Each table can have only one clustered index.


Question 4

A reporting system performs large aggregation queries against a fact table containing hundreds of millions of rows. Which index type is most appropriate?

A. Clustered columnstore index

B. Nonclustered index

C. Filtered index

D. XML index

Answer: A

Explanation: Clustered columnstore indexes are optimized for large analytical workloads, providing high compression and fast aggregations.


Question 5

Why might a developer create a filtered index?

A. To improve backup performance

B. To index only rows matching a specific condition

C. To encrypt indexed values

D. To automatically partition a table

Answer: B

Explanation: A filtered index includes only rows that satisfy a defined predicate, reducing storage and maintenance while improving performance for targeted queries.


Question 6

A table has a composite index on (OrderDate, CustomerID). Which query is most likely to benefit directly from the index?

A. Filtering only on CustomerID

B. Filtering only on ProductID

C. Filtering on OrderDate

D. Filtering only on TotalAmount

Answer: C

Explanation: Composite indexes are most effective when queries use the leftmost indexed column. A filter on OrderDate can efficiently leverage the index.


Question 7

Which statement about clustered indexes is correct?

A. A table can have many clustered indexes.

B. Clustered indexes cannot contain primary keys.

C. Clustered indexes store data separately from the table.

D. A table can have only one clustered index.

Answer: D

Explanation: Because a clustered index defines the physical order of the rows, only one clustered index can exist per table.


Question 8

A developer wants to eliminate expensive key lookups for a frequently executed query without changing the indexed search column. Which feature should be used?

A. Sparse columns

B. Included columns

C. Identity columns

D. Computed columns

Answer: B

Explanation: Included columns allow additional non-key columns to be stored in a nonclustered index, creating a covering index that can avoid key lookups.


Question 9

Which data type is recommended for storing currency values that require exact precision?

A. FLOAT

B. REAL

C. DECIMAL

D. MONEY with floating-point conversion

Answer: C

Explanation: DECIMAL provides fixed precision and scale, making it appropriate for financial calculations where exact values are required.


Question 10

Why are columnstore indexes particularly valuable for AI and analytics workloads?

A. They increase transaction locking.

B. They optimize sequential identity generation.

C. They eliminate the need for primary keys.

D. They provide high compression and significantly accelerate large scan and aggregation queries.

Answer: D

Explanation: Columnstore indexes organize data by column, enabling excellent compression and efficient execution of analytical queries common in reporting, feature engineering, and AI scenarios.


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

Identify common database objects (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:
Identify considerations for relational data on Azure (20–25%)
--> Describe relational concepts
--> Identify common database objects


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.

Relational databases are composed of several key database objects that define how data is stored, accessed, secured, and optimized. For the DP-900 exam, you should understand the purpose of these objects and how they support relational data systems.


What Are Database Objects?

Database objects are logical structures within a database used to:

  • Store data
  • Organize data
  • Enforce rules
  • Improve performance
  • Control access

They are created and managed using Structured Query Language (SQL).


Core Database Objects You Need to Know


1. Tables

A table is the primary object used to store data.

  • Organized into rows (records) and columns (fields)
  • Each table represents an entity (e.g., Customers, Orders)
  • Data is physically stored in tables

Example:

CustomerIDNameCity
1JohnSeattle

✔ Tables are the foundation of relational databases.


2. Views

A view is a virtual table based on a SQL query.

  • Does not store data physically (in most cases)
  • Displays data from one or more tables
  • Simplifies complex queries
  • Can restrict access to sensitive data

Example Use Case:

  • Show only customer names and cities, hiding confidential columns

✔ Views provide abstraction and security.


3. Indexes

An index is used to improve query performance.

  • Speeds up data retrieval
  • Works like an index in a book
  • Created on one or more columns
  • Improves SELECT performance but may slightly slow writes

Example:

  • Index on CustomerID for fast lookups

✔ Indexes are critical for performance optimization.


4. Stored Procedures

A stored procedure is a saved collection of SQL statements.

  • Stored and executed in the database
  • Can accept parameters
  • Can include logic (conditions, loops)
  • Improves performance and reusability

Example Use Case:

  • Retrieve all orders for a specific customer

✔ Stored procedures enable automation and reusable logic.


5. Schemas

A schema is a logical container for database objects.

  • Organizes tables, views, and other objects
  • Helps manage permissions
  • Improves structure and maintainability

Example:

  • Sales.Customers
  • HR.Employees

✔ Schemas help with organization and security management.


6. Keys

Keys define relationships and ensure data uniqueness.

Primary Key

  • Uniquely identifies each row
  • Cannot contain NULL values

Foreign Key

  • Links one table to another
  • Enforces referential integrity

✔ Keys are essential for relationships and data integrity.


7. Constraints

Constraints enforce rules on data to maintain accuracy.

Common constraints include:

  • PRIMARY KEY → unique identifier
  • FOREIGN KEY → enforces relationships
  • NOT NULL → requires a value
  • UNIQUE → prevents duplicates
  • CHECK → enforces conditions

✔ Constraints ensure data validity and consistency.


How These Objects Work Together

In a typical relational database:

  • Tables store the data
  • Keys and constraints enforce rules
  • Indexes improve performance
  • Views simplify access
  • Stored procedures automate operations
  • Schemas organize everything

Database Objects in Azure

These objects are used in Azure relational services such as:

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

These platforms support standard SQL-based database objects and functionality.


Why This Matters for DP-900

On the exam, you may be asked to:

  • Identify different database objects
  • Match objects to their purpose
  • Distinguish between tables, views, and indexes
  • Understand how objects support performance, security, and organization

Summary — Exam-Relevant Takeaways

✔ Tables → store data
✔ Views → virtual representation of data
✔ Indexes → improve query performance
✔ Stored procedures → reusable SQL logic
✔ Schemas → organize objects
✔ Keys → define relationships
✔ Constraints → enforce data rules

✔ Together, these objects ensure:

  • Efficient data storage
  • Fast data retrieval
  • Strong data integrity
  • Secure and organized systems

Go to the Practice Exam Questions for this topic.

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

Practice Questions: Identify common database objects (DP-900 Exam Prep)

Practice Questions


Question 1

Which database object is used to store data in rows and columns?

A. View
B. Table
C. Index
D. Schema

✅ Answer: B

Explanation:
Tables are the primary objects used to store structured data.


Question 2

Which database object provides a virtual representation of data without storing it physically?

A. Table
B. Index
C. View
D. Constraint

✅ Answer: C

Explanation:
Views display data based on a query but typically do not store data themselves.


Question 3

What is the primary purpose of an index?

A. Store data
B. Enforce relationships
C. Improve query performance
D. Organize database objects

✅ Answer: C

Explanation:
Indexes speed up data retrieval operations.


Question 4

Which database object allows you to store and reuse a set of SQL statements?

A. View
B. Stored procedure
C. Schema
D. Index

✅ Answer: B

Explanation:
Stored procedures contain reusable SQL logic and can include parameters and control flow.


Question 5

Which database object is used to logically group other database objects?

A. Table
B. Schema
C. Index
D. Constraint

✅ Answer: B

Explanation:
Schemas organize database objects and help manage permissions.


Question 6

Which object ensures that each row in a table is uniquely identified?

A. Foreign key
B. Index
C. Primary key
D. View

✅ Answer: C

Explanation:
A primary key uniquely identifies each record in a table.


Question 7

Which database object enforces relationships between tables?

A. Schema
B. Foreign key
C. Index
D. Stored procedure

✅ Answer: B

Explanation:
Foreign keys link tables and enforce referential integrity.


Question 8

Which constraint prevents duplicate values in a column?

A. NOT NULL
B. CHECK
C. UNIQUE
D. FOREIGN KEY

✅ Answer: C

Explanation:
The UNIQUE constraint ensures all values in a column are distinct.


Question 9

Which database object is MOST useful for restricting access to specific columns of data?

A. Table
B. Index
C. View
D. Primary key

✅ Answer: C

Explanation:
Views can limit which columns or rows are exposed to users.


Question 10

Which object may slightly decrease write performance due to maintenance overhead?

A. View
B. Index
C. Schema
D. Constraint

✅ Answer: B

Explanation:
Indexes improve read performance but can slow down inserts and updates.


✅ Quick Exam Takeaways

For DP-900, remember:

✔ Tables → store data
✔ Views → virtual tables (security + simplicity)
✔ Indexes → improve performance (reads ↑, writes ↓ slightly)
✔ Stored procedures → reusable SQL logic
✔ Schemas → organize objects
✔ Primary keys → unique identifiers
✔ Foreign keys → relationships
✔ Constraints → enforce rules (NOT NULL, UNIQUE, etc.)


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