Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Implement JWT in a Project
00:00
5 left

Implement JWT in a Project

HardSQL · PostgreSQL

Problem

How did you implement JWT in your project?

Translate the implementation into a PostgreSQL audit query over JWT tokens and API requests. As of 2025-02-01, summarize every token, including tokens with no requests. Treat a request at or after expiration or revocation as invalid.

Output

  1. One row per JWT token with token_id, user_id, token_status, request_count, last_request_at, and invalid_request_count
  2. Include active, expired, revoked, and unused tokens
  3. Order by token_id ascending

Schema

jwt_tokens
ColumnTypeDescription
token_idPKINTUnique JWT token identifier
user_idINTIdentifier of the token owner
issued_atTIMESTAMPToken issuance timestamp
expires_atTIMESTAMPToken expiration timestamp
revoked_atTIMESTAMPTimestamp when the token was revoked
scopeVARCHAR(50)Permissions encoded for the token
api_requests
ColumnTypeDescription
request_idPKINTUnique API request identifier
token_idINTJWT token used for the request
requested_atTIMESTAMPTimestamp when the request was received
endpointVARCHAR(100)Requested API endpoint
response_statusINTHTTP response status code
Tablesjwt_tokensapi_requests
Interviewer

Your question is Implement JWT in a Project. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.