Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Flag Multi-Source Alert Relationships

MediumSQL · PostgreSQL00:00
I
Practice interviewer
In session
5 left
00:00

Your question is Flag Multi-Source Alert Relationships. 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

You are given a small schema that models entities, alerts, and analyst investigations in a Foundry-style operational dataset. Write a PostgreSQL query that returns each entity created in January 2024 that has alerts from at least two distinct sources and at least one open investigation. For each qualifying entity, return the entity name, the number of distinct alert sources, the total number of alerts in January 2024, and a priority label of high when the entity has 3 or more January alerts, otherwise medium.

Because you do not have a running database, you should reason from the schema and sample data and produce the exact result set shown below.

Schema

entities
ColumnTypeDescription
entity_idPKINTPrimary key for the entity
entity_nameVARCHAR(100)Display name for the entity
entity_typeVARCHAR(50)Type of entity such as device, account, or person
created_atDATEDate the entity record was created
alerts
ColumnTypeDescription
alert_idPKINTPrimary key for the alert
entity_idINTEntity associated with the alert
source_systemVARCHAR(50)System that generated the alert
severityVARCHAR(20)Alert severity level
alert_dateDATEDate the alert was generated
investigations
ColumnTypeDescription
investigation_idPKINTPrimary key for the investigation
entity_idINTEntity under investigation
statusVARCHAR(20)Current investigation status
opened_atDATEDate the investigation was opened
Tablesentitiesalertsinvestigations
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results