skip to content

Access Control & Data Protection

I learn how a relational database decides who may connect and what each account may do to the data, and how the engine protects data it stores and transmits. Interviewers use this area to test whether I can design least-privilege access for a real application, not just write queries as a superuser.

part ofRelational database conceptsoverview, primer and where to startread it →
on this pageshow

questions

page 2 of 2

A database session has been open for an hour. An administrator now removes that session's access to a table. Does the session lose access immediately? Explain when a database evaluates privileges relative to when the connection was authenticated.

level: seniorimportance: should knowfreq 38%

basics

~20 s

Yes, effectively. Privileges are read from the catalog when a statement executes, not cached at connect time, so the session's next statement fails once the change commits. A statement already running finishes, and removing login rights or credentials does not disconnect anyone — you must terminate the session.

open as a page

Some database deployments require each client to present its own X.509 certificate before the session is accepted. What does that buy over a password, and what operational burden does it add?

level: seniorimportance: should knowfreq 35%

basics

~20 s

A client certificate proves who is connecting without sending a reusable shared secret, and the server maps the certificate subject to a database role. The cost is a full certificate lifecycle: issuance per service, secure distribution, short expiry causing outages, and revocation that is hard to make timely.

open as a page

You are asked to make a production database refuse every unencrypted client connection. How do you get there without an outage, and what keeps it working afterwards?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Measure first: list live connections and which are unencrypted. Enable TLS server-side while still accepting plaintext, migrate every client to verified TLS with the CA bundle shipped, watch the plaintext count reach zero, then flip the server rule to reject non-TLS. Afterwards, automate renewal and alert on certificate expiry.

open as a page

A reporting role was granted SELECT on every table in a schema, and a week later new tables in that same schema are unreadable to it. Why does that happen, and how is it normally handled?

level: seniorimportance: should knowfreq 35%

basics

~20 s

A bulk grant over a schema is expanded once, at execution time, into one stored privilege per existing object. Objects created later have no such privilege. Fixes: engine-level default-privilege rules keyed to the creating role, granting the privileges in the same migration that creates the object, or a reconciliation job.

open as a page

Your service uses a connection pool, so every database session authenticates as one shared application account and the database has no idea which end user made the request. What are the consequences, and what techniques let you re-introduce per-user identity?

level: seniorimportance: should knowfreq 38%

basics

~20 s

The database sees only the pooled account, so its audit trail, row-level policies and per-user limits cannot distinguish end users - authorization must be enforced in the application. To restore identity you either set a per-transaction session variable the database reads, or switch identity with SET ROLE after checkout, and you must reset that state before returning the connection to the pool.

open as a page

A role has been granted SELECT on every table in a schema, yet it cannot read a table created last week. Why does that happen, and what mechanism makes access apply to objects created in the future?

level: seniorimportance: should knowfreq 34%

basics

~20 s

Granting on all tables in a schema is a one-time bulk operation over the tables that existed at that moment, not a standing rule. New objects carry no grants for non-owners. Default privileges - configured per creating role and schema - attach chosen grants automatically to objects created later.

open as a page

What does it mean to own a database object, what does the owner implicitly get that a grantee does not, and how would you decide who or what should own a production schema?

level: seniorimportance: should knowfreq 38%

basics

~20 s

The owner is the role that created the object or was later assigned it. Owners implicitly hold every privilege on it, can ALTER and DROP it, can grant rights to others, and in most engines are exempt from row-level policies on it. Production objects should be owned by a dedicated NOLOGIN role that people and pipelines are granted membership in - never by an individual.

open as a page

Row policies are enabled on a table, yet the application still reads every tenant's rows in production. What ownership or privilege explanations would you check, and how do you close each one?

level: seniorimportance: should knowfreq 34%

basics

~20 s

Usual causes: the app connects as the table owner (owners bypass policies unless RLS is forced), as a superuser, or as a role flagged to bypass RLS; an extra permissive policy OR-ed in a wide predicate; or reads go through a view or function that runs with the definer's privileges.

open as a page

Many services read one shared customer database. How would you decide where personal-data redaction lives — database masking policies, restricted views, the application layer, or a separate tokenised store — and how would you prove the choice holds?

level: principalimportance: should knowfreq 28%

basics

~20 s

Push enforcement to the lowest layer every reader must pass. If teams hold their own SQL credentials, that is the database: restricted views plus column privileges. Reserve tokenisation for the highest-sensitivity fields, and prove it with automated privilege tests and PII scans of every copy.

open as a page

A team argues that because their application servers and database run inside one private network, encrypting the database connections is unnecessary overhead. How do you decide?

level: principalimportance: should knowfreq 25%

basics

~20 s

Decide from the threat model, not the network label. A private network stops outsiders, not a compromised neighbour, an insider, or the infrastructure operator. With modern CPUs and pooled connections the cost is negligible, so default to verified TLS everywhere and treat exceptions as time-boxed, justified by measured latency, never by 'it is internal'.

open as a page

For a multi-tenant SaaS product on a relational database, how would you choose between enforcing tenant isolation with row policies, a schema per tenant, or a database per tenant?

level: principalimportance: should knowfreq 28%

basics

~20 s

Trade blast radius against operational cost. Row policies: one shared schema, cheapest to operate and migrate, isolation depends on correct policies and context. Schema per tenant: stronger separation, migration cost grows with tenant count. Database per tenant: strongest isolation and per-tenant restore, heaviest to run.

open as a page

How does client-certificate authentication (mutual TLS) to a database work, and what operational burdens does it add compared with password authentication?

level: seniorimportance: nice to knowfreq 28%

basics

~20 s

During the TLS handshake the client presents a certificate; the server validates its chain against a trusted CA, checks validity and revocation, then maps the certificate subject to a database role. There is no shared secret to steal, but you now own a PKI: issuance, rotation before expiry, and revocation distribution.

open as a page

Compare authenticating database users against an LDAP directory with using Kerberos/GSSAPI. What are the security and operational differences, and what stays in the database either way?

level: seniorimportance: nice to knowfreq 30%

basics

~20 s

With LDAP the client sends its password to the database, which re-binds to the directory to verify it — so the database sees the plaintext password and needs TLS to the directory. With Kerberos the client presents a ticket obtained elsewhere; no password reaches the database, and single sign-on works. Both externalise identity only — roles and privileges stay in the database.

open as a page

You are asked to enable comprehensive database auditing on a high-throughput transactional system without wrecking its latency, its disk budget, or your log-ingest bill. How do you decide what to capture and how long to keep it?

level: principalimportance: nice to knowfreq 26%

basics

~20 s

Start from the control objectives and regulated scope, not from what the engine can emit. Capture the near-free classes always (logins, DDL, privilege changes, privileged sessions), scope data auditing to sensitive objects, put audit output on separate storage off the host, and tier retention — hot searchable weeks, cold archive years, then delete.

open as a page

Across a system of a dozen services sharing one relational database cluster, how would you decide how many distinct database accounts to create and how narrowly to scope each one?

level: principalimportance: nice to knowfreq 28%

basics

~20 s

Cut accounts along blast-radius boundaries, not along code structure: one runtime account per service (and per data-sensitivity tier within it), separate migration and read-only identities, and a separate schema or database wherever the data classification differs. Finer scoping costs grant maintenance and credential rotation, so stop where the marginal containment stops paying.

open as a page

showing 31–45 of 45