Lesson 4 of 4 Relational Data Solutions

Layering Protection for Relational Data

This lesson explains how encryption, masking, row-level security and auditing combine.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish TDE from Always Encrypted.
  • Describe dynamic data masking and row-level security.
  • Explain the purpose of ledger, auditing and Defender for SQL.

Layers of protection

No single feature secures a database. A design combines network controls that limit who can reach it, identity controls that limit who can sign in, data controls that protect information even from people who can connect, and monitoring that detects misuse. The requirement in a scenario usually identifies which layer is missing.

The following diagram matches four requirements for patient records to an Azure SQL security feature.

Four patient-record requirements, four Azure SQL features. Always Encrypted keeps national insurance numbers from administrators, because only client-side encryption withholds plaintext from privileged users; dynamic data masking shows support staff the last four digits; row-level security limits doctors to their patients; and ledger proves history was not altered.
The scenario is illustrative.

Network and identity

Azure SQL Database has a public endpoint controlled by firewall rules. Stronger designs use a private endpoint and deny public network access altogether, so that only clients with a network path can connect. SQL Managed Instance runs inside a virtual network subnet by design.

Sign-ins should use Microsoft Entra authentication rather than SQL logins wherever possible. This gives central identity, MFA, Conditional Access and managed identities for applications, removing database passwords. A database can be set to Microsoft Entra-only authentication, which disables SQL authentication altogether.

Encrypting data

Encryption addresses different threats according to when it applies.

Transparent data encryption

Transparent data encryption (TDE) encrypts data files, logs and backups at rest. It is on by default for new databases, with a service-managed key, and it needs no application change. A customer-managed key in Key Vault adds control of the key. TDE protects against stolen media or backups. It does not protect data from a person who can query the database, since data is decrypted transparently for authorized connections.

Encryption in transit

Connections use Transport Layer Security, and a minimum TLS version should be set on the server.

Always Encrypted

Always Encrypted encrypts selected columns inside the client application, and the keys are never exposed to the database engine. Even a database administrator sees only ciphertext, which is what distinguishes it from TDE. The application needs a driver that supports it, and the keys are usually held in Key Vault. Query capabilities on encrypted columns are limited. Always Encrypted with secure enclaves extends these capabilities, though enclaves based on Intel SGX reach end of support on 31 October 2027, so new designs should use VBS enclaves.

The next comparison distinguishes the two main encryption features, a very common exam topic.

Transparent data encryption
What is protectedThe whole database at rest
Where encryption happensDatabase engine
Visible to a database administratorYes, through queries
Application changeNone
Choose when Protect files and backups
Always Encrypted
What is protectedSelected columns, at rest, in transit and in use
Where encryption happensClient driver
Visible to a database administratorNo
Application changeDriver and key configuration
Choose when Hide data from privileged database users
Sort into groups

TDE or Always Encrypted?

Exam skills 2.1.4

Decide which encryption feature meets each requirement.

Log in to try this activity Interactive activities are free with an account.

Limiting what users see

Dynamic data masking hides part of a value in query results for users without the unmask permission: a card number might appear as a series of Xs with the last four digits shown. The stored data does not change, and masking does not defeat a determined user who can run inference queries, so it is a convenience for limiting casual exposure rather than a security boundary.

Row-level security filters which rows a user can read or change, according to a predicate that runs in the database, such as showing each sales representative only their own customers. It suits multi-tenant data held in shared tables. Column-level permissions restrict access to particular columns through standard GRANT statements. Together, these features let many users share one database and see only what they should.

Scenario questions

Limiting exposure

Exam skills 2.1.4

Choose the feature that limits what users see in each case.

Log in to try this activity Interactive activities are free with an account.

Tamper evidence, auditing and threat detection

Ledger makes tables tamper-evident: it uses cryptographic hashes to allow later proof that data has not been altered, even by privileged users. It suits regulated records and any scenario demanding proof of integrity, without a separate blockchain.

Azure SQL auditing records database events to a Log Analytics workspace, an event hub or storage, which can then support investigations. Microsoft Defender for SQL adds vulnerability assessment, which finds misconfiguration, and threat protection, which alerts on anomalies such as SQL injection attempts. Data discovery and classification labels sensitive columns, helping to focus these controls and report on them.

Match the pairs

Detect and prove

Exam skills 2.1.4

Match each requirement with the Azure SQL feature that meets it.

Log in to try this activity Interactive activities are free with an account.
Worked example

Layering database controls

A hospital stores patient records in Azure SQL Database. Database administrators must be able to maintain the database but must never see national insurance numbers. Support staff should see only the last four digits of phone numbers. Each doctor may see only their own patients. Auditors want proof that historical records were never altered. Which feature meets each requirement?

Hiding national insurance numbers from administrators needs Always Encrypted, because only client-side encryption withholds the plaintext from privileged database users. Showing support staff partial phone numbers is dynamic data masking. Restricting doctors to their own patients is row-level security.

Proving that records were not altered is ledger. TDE, which is already on, would not meet any of these requirements, since all of them concern people who connect successfully. Each feature addresses a distinct threat, and this is why a real design layers them.

Check yourself

A database administrator can read a column protected by TDE. Why?

Show answer

TDE protects data at rest, and data is decrypted for authorized connections. Hiding data from administrators requires Always Encrypted.

Exam Tips

Remember for the exam

  • TDE protects data at rest and backups; Always Encrypted hides columns from database administrators.
  • Dynamic data masking changes query results, not stored data, and is not a strong security boundary.
  • Row-level security filters rows by a predicate.
  • Ledger proves that data has not been tampered with.
  • Prefer Microsoft Entra authentication and private endpoints.