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.

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.
TDE or Always Encrypted?
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.
Limiting exposure
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.
Detect and prove
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.
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.