Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Securing Sensitive Data

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Securing Sensitive Data. Start with the requirements and the three tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

How would you handle permissions and security on sensitive data sets?

Translate the access policy into a PostgreSQL query that returns only currently authorized dataset grants. Sensitive datasets require an active user, enabled MFA, and an approved security role. Standard datasets require only an active user and a valid grant.

Output

  1. One row per authorized grant
  2. Columns: email, dataset_name, classification, permission_level, granted_role, and access_scope
  3. Exclude inactive users, inactive datasets, revoked grants, expired grants, and unauthorized sensitive access
  4. Order by email, then dataset_name

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
emailVARCHAR(255)User email address
roleVARCHAR(50)User security role
is_activeBOOLEANWhether the user account is active
mfa_enabledBOOLEANWhether multi-factor authentication is enabled
datasets
ColumnTypeDescription
dataset_idPKINTUnique dataset identifier
dataset_nameVARCHAR(150)Dataset name
classificationVARCHAR(30)Data classification such as public, internal, restricted, or secret
owner_teamVARCHAR(100)Team responsible for the dataset
is_activeBOOLEANWhether the dataset is available
access_grants
ColumnTypeDescription
grant_idPKINTUnique grant identifier
user_idINTUser receiving the grant
dataset_idINTDataset covered by the grant
permission_levelVARCHAR(30)Granted access level
granted_roleVARCHAR(50)Role recorded when access was granted
revoked_atDATEDate the grant was revoked
expires_atDATEGrant expiration date
Tablesusersdatasetsaccess_grants
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results