Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Navigational Result for Query

MediumSQL & Data Manipulation00:00
Practice interviewer
In session
5 left
00:00

Your question is Navigational Result for Query. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

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

Problem

Telus Digital does search-quality contract work for a search engine client. Their business rule: a query is 'navigational' if the site's known canonical domain appears anywhere in the top 3 organic (non-sponsored) results. You're given the sample data and the analyst's query below.

CREATE TABLE known_destinations (
    query_text VARCHAR(80),
    canonical_domain VARCHAR(80)
);
INSERT INTO known_destinations VALUES ('delta airlines', 'delta.com');
-- note: 'best running shoes' has no row here -- it has no single canonical destination

CREATE TABLE search_results (
    query_text VARCHAR(80),
    position INT,
    result_domain VARCHAR(80),
    result_type VARCHAR(20)  -- 'organic' or 'sponsored'
);
INSERT INTO search_results VALUES
    ('delta airlines', 1, 'ad.delta-deals.com', 'sponsored'),
    ('delta airlines', 2, 'expedia.com', 'organic'),
    ('delta airlines', 3, 'www.delta.com', 'organic'),
    ('delta airlines', 4, 'tripadvisor.com', 'organic'),
    ('best running shoes', 1, 'nike.com', 'organic'),
    ('best running shoes', 2, 'runnersworld.com', 'organic');

SELECT kd.query_text, sr.result_domain AS navigational_match
FROM known_destinations kd
JOIN search_results sr
    ON sr.query_text = kd.query_text
   AND sr.result_domain = kd.canonical_domain
WHERE sr.position = 1;

Using the sample data above, is there a navigational result for 'delta airlines'? Explain what this query actually returns, whether that's correct per the business rule, and what you'd change.