Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Start free
Database Availability Strategy
00:00
5 left

Database Availability Strategy

HardSQL · PostgreSQL

Problem

Describe your strategy for managing and optimizing databases to ensure high availability in large-scale data systems like those at Johnson & Johnson.

For a hands-on SQL response, use the supplied database cluster, instance, and availability event data to produce a production health report for January 2025.

Output

  1. One row per production cluster, including clusters without instances or incidents.
  2. Return cluster_name, environment, instance_count, standby_count, max_replication_lag_seconds, downtime_hours, incident_count, and availability_pct.
  3. Treat missing metrics as zero, calculate availability against 744 hours, and order by availability_pct ascending, then cluster_name ascending.

Schema

database_clusters
ColumnTypeDescription
cluster_idPKINTUnique database cluster identifier
cluster_nameVARCHAR(80)Database cluster name
environmentVARCHAR(30)Deployment environment
database_instances
ColumnTypeDescription
instance_idPKINTUnique database instance identifier
cluster_idINTOwning database cluster
roleVARCHAR(20)Instance role, such as PRIMARY or STANDBY
replication_lag_secondsINTCurrent replication lag in seconds
availability_events
ColumnTypeDescription
event_idPKINTUnique availability event identifier
cluster_idINTAffected database cluster
started_atTIMESTAMPEvent start timestamp
resolved_atTIMESTAMPEvent resolution timestamp
incident_typeVARCHAR(40)Availability incident classification
Tablesdatabase_clustersdatabase_instancesavailability_events
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.