Streaming SQL · Kafka · Flink · Graph Queries · Guide + 25 Interview Questions

Streaming SQL & Graph Queries: Real-Time Data and Relationship Intelligence

Streaming SQL applies SQL to continuous, unbounded data streams instead of static tables. Graph queries navigate relationships between entities rather than rows in a table. Together, they represent the frontier of modern data engineering — real-time analytics with Kafka and Flink, and relationship intelligence with Cypher and GQL. This guide covers event streams, windows, watermarks, state, graph traversal, and the 25 interview questions that actually come up.

🎯 Key Takeaways
25 Interview Questions Beginner to Advanced Kafka, Flink, Cypher, GQL Updated Dec 3, 2026
Kailas Warade ✓ Verified Author
Data Engineer · Oracle Certified · SQL & PL/SQL
Kailas works with SQL, PL/SQL, Python, and PySpark to build data pipelines. He writes the SQL interview guides at Sankalan Data Tech, focused on practical, real-world answers.
🏆 Oracle Certified 💼 Data Engineer 📝 SQL & PL/SQL Guides 📍 Pune, India
📤 Share:

On This Page

What Streaming SQL Really Is

Streaming SQL is SQL applied to continuous, unbounded data streams instead of static tables. Instead of running a query once against stored data, you define a query that runs continuously as new events arrive.

The key difference is that a table has a fixed end — you query what is already there. A stream has no fixed end — new data keeps coming, and the query keeps producing new results.

Streaming SQL is used for real-time analytics, fraud detection, monitoring, IoT data processing, and event-driven applications. It is powered by engines like Apache Flink, Kafka Streams, and Spark Structured Streaming.

The mental model is simple: instead of "query the data that exists", you say "keep computing this result as new data arrives".

Kafka and Event Streaming

Apache Kafka is a distributed event streaming platform used to publish, subscribe to, store, and process event streams in real time. It is the backbone of many modern streaming architectures.

-- Kafka concepts
Topic:       a named stream of events
Producer:    writes events to a topic
Consumer:    reads events from a topic
Partition:   parallel unit within a topic
Offset:      position of an event within a partition

Kafka decouples producers from consumers. A producer writes events without knowing who will read them. A consumer reads events at its own pace. This makes the system scalable and fault-tolerant.

Kafka is often the source of streaming SQL queries. Flink reads from Kafka, processes the stream, and writes results to a sink.

Windows and Watermarks

A window groups events into bounded segments so you can compute aggregates over time. Common window types are tumbling, sliding, and session windows.

-- Tumbling window: fixed, non-overlapping
TUMBLE(order_time, INTERVAL '5' MINUTE)

-- Sliding window: overlapping
HOP(order_time, INTERVAL '1' MINUTE, INTERVAL '5' MINUTE)

-- Session window: gap-based
SESSION(order_time, INTERVAL '10' MINUTE)

A watermark tells the engine how long to wait for late-arriving events before finalizing a window. Without watermarks, the engine would never know when a window is "complete".

-- Watermark: allow events up to 5 seconds late
WATERMARK FOR order_time AS order_time - INTERVAL '5' SECOND

Watermarks are essential for event-time processing. They balance the trade-off between waiting for late data and producing results quickly.

Graph Databases and Cypher

A graph database stores data as nodes (entities) and edges (relationships). It is optimized for traversing relationships, such as social networks, fraud detection, and recommendation systems.

-- Graph model
(Person)-[:FOLLOWS]->(Person)
(Person)-[:PURCHASED]->(Product)
(Product)-[:BELONGS_TO]->(Category)

Cypher is a declarative graph query language used primarily with Neo4j. It uses ASCII-art patterns to match nodes and relationships.

-- Find friends of friends
MATCH (p:Person {name: 'Alice'})-[:FOLLOWS]->(f)-[:FOLLOWS]->(fof)
RETURN fof.name

This query finds people that Alice follows, then finds who those people follow. The pattern-based syntax makes graph traversal intuitive.

GQL and the Future of Graph Querying

GQL (Graph Query Language) is the ISO-standardized graph query language, designed to unify graph querying across databases. It builds on Cypher concepts and is becoming the standard for graph databases.

-- GQL example (similar to Cypher)
MATCH (p:Person)-[:FOLLOWS]->(f:Person)
WHERE p.name = 'Alice'
RETURN f.name

GQL aims to solve the fragmentation in graph querying — different databases used different languages. With GQL, the same query pattern works across compliant databases.

This is similar to how SQL standardized relational querying. GQL is doing the same for graph querying.

25 Streaming SQL & Graph Queries Interview Questions and Answers

These are the streaming SQL and graph query questions that come up most often in data engineering interviews. Every answer stands on its own — read them in any order, or work through them in sequence to build a complete understanding of streaming SQL, Kafka, Flink, graph databases, Cypher, and GQL.

🔍

No matching questions found

Try a keyword like Kafka, watermark, Cypher, or graph.

Streaming SQL is SQL applied to continuous, unbounded data streams instead of static tables. It processes events as they arrive, in real time.

-- Streaming SQL: runs continuously
SELECT
    TUMBLE_ROWTIME(order_time, INTERVAL '1' MINUTE) AS window_start,
    COUNT(*) AS order_count
FROM orders
GROUP BY TUMBLE(order_time, INTERVAL '1' MINUTE);

The key difference from batch SQL is that this query never "finishes". It keeps producing updated results as new events arrive.

Streaming SQL is powered by engines like Apache Flink, Kafka Streams, and Spark Structured Streaming.

A data stream is an unbounded, continuous sequence of events that arrives over time. Unlike a table, it has no fixed end — new data keeps coming.

-- Table: finite, stored
| id | name  | amount |
| 1  | Alice | 100    |
| 2  | Bob   | 200    |

-- Stream: unbounded, continuous
event 1 → event 2 → event 3 → ... (keeps coming)

Streams are common in IoT, clickstream, financial transactions, and log data. The challenge is that you cannot "wait for all the data" — you must process it as it arrives.

Apache Kafka is a distributed event streaming platform used to publish, subscribe to, store, and process event streams in real time.

-- Kafka architecture
Producer → Topic (partitioned) → Consumer

Kafka decouples producers from consumers. A producer writes events without knowing who will read them. A consumer reads events at its own pace.

Kafka is the backbone of many modern streaming architectures because it is scalable, fault-tolerant, and high-throughput.

Flink SQL is the SQL interface for Apache Flink, a stream processing engine. It lets you write SQL queries that run continuously over event streams.

SELECT
    TUMBLE_ROWTIME(order_time, INTERVAL '1' MINUTE) AS window_start,
    SUM(amount) AS total_amount
FROM orders
GROUP BY TUMBLE(order_time, INTERVAL '1' MINUTE);

Flink SQL supports windows, joins, aggregations, and stateful processing — all expressed in standard SQL syntax. This makes it accessible to analysts who already know SQL.

A watermark is a mechanism that tells the streaming engine how long to wait for late-arriving events before finalizing a window.

-- Allow events up to 5 seconds late
WATERMARK FOR order_time AS order_time - INTERVAL '5' SECOND

Without watermarks, the engine would never know when a window is "complete" because it cannot know if a late event is still coming.

Watermarks balance the trade-off between waiting for late data and producing results quickly. A larger watermark means more accurate results but higher latency.

A window groups events into bounded segments so you can compute aggregates over time. It is essential for streaming analytics.

-- Tumbling window: fixed, non-overlapping
TUMBLE(order_time, INTERVAL '5' MINUTE)

-- Sliding window: overlapping
HOP(order_time, INTERVAL '1' MINUTE, INTERVAL '5' MINUTE)

-- Session window: gap-based
SESSION(order_time, INTERVAL '10' MINUTE)

Tumbling windows are good for periodic reports. Sliding windows are good for moving averages. Session windows are good for user activity analysis.

A graph database stores data as nodes (entities) and edges (relationships). It is optimized for traversing relationships.

-- Graph model
(Person)-[:FOLLOWS]->(Person)
(Person)-[:PURCHASED]->(Product)
(Product)-[:BELONGS_TO]->(Category)

Graph databases excel at use cases where relationships are the main query pattern: social networks, fraud detection, recommendation systems, and knowledge graphs.

Unlike relational databases, which use joins to traverse relationships, graph databases traverse edges directly, which is faster for deep, multi-hop queries.

Cypher is a declarative graph query language used primarily with Neo4j. It uses ASCII-art patterns to match nodes and relationships.

-- Find friends of friends
MATCH (p:Person {name: 'Alice'})-[:FOLLOWS]->(f)-[:FOLLOWS]->(fof)
RETURN fof.name

The pattern `(p)-[:FOLLOWS]->(f)` reads like a diagram: person follows person. This makes graph queries intuitive and easy to read.

Cypher is the most widely used graph query language and the foundation for GQL.

GQL (Graph Query Language) is the ISO-standardized graph query language, designed to unify graph querying across databases.

-- GQL example
MATCH (p:Person)-[:FOLLOWS]->(f:Person)
WHERE p.name = 'Alice'
RETURN f.name

GQL builds on Cypher concepts and aims to solve the fragmentation in graph querying. Different databases used different languages; GQL standardizes them.

This is similar to how SQL standardized relational querying. GQL is doing the same for graph querying.

Graph traversal is the process of navigating from node to node through edges to find paths, patterns, or relationships.

-- Traversal: Alice → Bob → Charlie
MATCH (a:Person {name:'Alice'})-[:FOLLOWS]->(b)-[:FOLLOWS]->(c)
RETURN c.name

Traversal is the core operation in graph databases. The number of hops (edges crossed) determines query depth. Deep traversals (many hops) are where graph databases shine compared to relational joins.

Batch processing handles finite, stored datasets after the fact. Streaming processing handles continuous, unbounded data in real time as events arrive.

Aspect Batch Streaming
Data Finite, stored Unbounded, continuous
Latency Minutes to hours Milliseconds to seconds
Query model Run once Run continuously
Use case Reports, ETL Fraud detection, monitoring

The choice depends on latency requirements. If you can wait, batch is simpler and cheaper. If you need real-time action, streaming is necessary.

Event time is when the event actually occurred (embedded in the event). Processing time is when the system processes the event.

-- Event time: 2026-12-03 10:00:00 (when it happened)
-- Processing time: 2026-12-03 10:00:03 (when system saw it)

Event time is preferred for accurate analytics because it is not affected by network delays or processing backlogs. Processing time is simpler but can give wrong results if events arrive late.

Watermarks are built around event time to handle this gap.

Exactly-once processing guarantees that each event is processed exactly one time, even in the case of failures.

-- At-least-once: event may be processed multiple times
-- At-most-once: event may be lost
-- Exactly-once: event processed exactly once

Exactly-once is critical for financial and transactional streaming workloads where duplicates or losses are unacceptable.

Flink achieves this through checkpointing and transactional sinks. It is harder to achieve than at-least-once but necessary for correctness.

State is data the streaming engine keeps between events, such as running totals, session data, or join buffers.

-- Stateful aggregation
Running total: 100 → 300 → 600 → ...

-- Stateful join
Buffer left events until matching right event arrives

Stateful processing enables complex analytics over streams. Without state, you can only do simple per-event transformations.

State must be managed carefully — it can grow unbounded if not cleaned up, causing memory issues.

A sink is the destination where processed streaming results are written, such as a database, another Kafka topic, or a dashboard.

-- Streaming pipeline
Kafka source → Flink SQL → Sink (database/Kafka/dashboard)

The sink determines how results are consumed downstream. A database sink enables querying. A Kafka sink enables further stream processing. A dashboard sink enables real-time visualization.

Backpressure is when a downstream component cannot keep up with the rate of incoming data, causing upstream components to slow down.

-- Backpressure flow
Fast producer → Slow consumer → data piles up

Backpressure is a signal that the pipeline is overloaded. It can cause latency spikes or data loss if not handled.

Solutions include scaling consumers, optimizing slow operators, or adding buffering.

Checkpointing is Flink's mechanism for fault tolerance. It periodically saves the state of the streaming job so it can recover after a failure.

-- Checkpoint interval
execution.checkpointing.interval = 10s

When a failure occurs, Flink restores the last checkpoint and continues from there. This enables exactly-once processing.

Checkpointing is essential for production streaming jobs — without it, a failure means losing state and reprocessing data.

A Kafka partition is a parallel unit within a topic. Events within a partition are ordered, but events across partitions are not.

-- Topic with 3 partitions
Partition 0: event1, event4, event7
Partition 1: event2, event5, event8
Partition 2: event3, event6, event9

Partitions enable parallelism — more partitions mean more consumers can read in parallel. But ordering is only guaranteed within a partition, not across the topic.

Choosing the right number of partitions is a key design decision in Kafka.

A consumer group is a set of consumers that share the work of reading a topic. Each partition is read by exactly one consumer in the group.

-- Topic with 3 partitions, consumer group with 3 consumers
Consumer 1 → Partition 0
Consumer 2 → Partition 1
Consumer 3 → Partition 2

Consumer groups enable horizontal scaling. Adding more consumers (up to the number of partitions) increases throughput.

If there are more consumers than partitions, extra consumers sit idle.

A streaming join combines events from two streams based on a key, but unlike batch joins, events arrive at different times.

-- Stream-stream join: match orders with payments
SELECT o.order_id, p.payment_id
FROM orders o
JOIN payments p
    ON o.order_id = p.order_id;

The challenge is that the payment may arrive after the order. The engine must buffer one side until the matching event arrives — this is stateful processing.

Time bounds (like a window) are usually needed to prevent unbounded state growth.

A property graph model stores data as nodes and edges, where both can have properties (key-value pairs).

-- Property graph
(Person {name:'Alice', age:30})-[:FOLLOWS {since:2020}]->(Person {name:'Bob'})

This is the most common graph model in practice. Both nodes and edges carry data, making it flexible for real-world modeling.

Neo4j, Amazon Neptune, and TigerGraph all use the property graph model.

A shortest path query finds the minimum number of hops (or lowest cost) between two nodes in a graph.

-- Cypher: shortest path
MATCH p = shortestPath((a:Person {name:'Alice'})-[*]-(b:Person {name:'Charlie'}))
RETURN p

Shortest path is a classic graph problem. It is used in routing, social network analysis, and fraud detection (finding hidden connections).

A recommendation query finds items or people connected to a user through their network, often using collaborative filtering patterns.

-- Recommend products based on what friends bought
MATCH (p:Person {name:'Alice'})-[:FOLLOWS]->(f)-[:PURCHASED]->(prod)
WHERE NOT (p)-[:PURCHASED]->(prod)
RETURN prod.name, COUNT(*) AS score
ORDER BY score DESC

This query finds products that Alice's friends bought but Alice has not bought yet, ranked by how many friends bought them. This is a classic graph-based recommendation pattern.

Streaming and graph queries combine when you need real-time relationship intelligence — such as fraud detection or real-time recommendations.

-- Real-time fraud detection
Kafka event → Flink SQL (enrich, aggregate) → Graph update → Cypher query (fraud pattern)

For example, a streaming pipeline processes transactions in real time, updates a graph of accounts and transactions, and runs a Cypher query to detect fraud patterns (like circular money flows).

This combination is powerful because streaming provides speed and graph provides relationship depth.

Streaming SQL solves real problems, but it brings challenges of its own.

  • Late data: Events arrive after their window has closed. Watermarks help but cannot eliminate the problem.
  • State management: State can grow unbounded if not cleaned up, causing memory issues.
  • Exactly-once semantics: Hard to achieve, requires checkpointing and transactional sinks.
  • Backpressure: Downstream slowness cascades upstream, causing latency spikes.
  • Complexity: Streaming systems are harder to debug and operate than batch systems.
  • Cost: Running streaming jobs 24/7 costs more than batch jobs run periodically.

The rule of thumb: use streaming only when the business need justifies the added complexity. If you can wait, batch is simpler and cheaper.

Mistakes I Keep Seeing in Interviews

These come up repeatedly. None of them are exotic, and every one of them is easy to avoid once you know it is coming.

Mistake one: confusing streaming with batch. Candidates say "streaming is just faster batch" — it is not. The data model, semantics, and challenges are fundamentally different.
Mistake two: not knowing what a watermark is. This is the single most common streaming interview question, and not knowing it is a red flag.
Mistake three: confusing event time with processing time. This is a basic but critical distinction that separates good candidates from great ones.
Mistake four: assuming graph queries are just SQL with different syntax. Graph queries think in terms of traversal and patterns, not rows and columns.
Mistake five: not understanding state. Streaming without state is just per-event transformation — the real power comes from stateful processing.
Mistake six: ignoring exactly-once semantics. For financial or transactional workloads, this is not optional — it is a correctness requirement.

Follow-Up Questions Interviewers Ask

Getting the first answer right is only half the interview. What usually decides the outcome is what happens next. Here is what to prepare for on the streaming and graph topics.

After “What is Streaming SQL?” — expect

  • “How does it differ from batch SQL?”
  • “What engines support it?”
  • “What is a window?”
  • “What is a watermark?”

After “Kafka” — expect

  • “What is a partition?”
  • “What is a consumer group?”
  • “How does Kafka handle fault tolerance?”
  • “What is an offset?”

After “Watermarks” — expect

  • “What happens to late events?”
  • “How do you choose the watermark delay?”
  • “What is the trade-off?”
  • “What is allowed lateness?”

After “Graph queries” — expect

  • “What is a property graph?”
  • “How does Cypher differ from SQL?”
  • “What is graph traversal?”
  • “What is GQL and why does it matter?”

For every question above, prepare a second-level answer. The candidates who pass are not the ones who memorized the first answer — they are the ones who kept going for another thirty seconds and said something useful about why it matters.

Quick Quiz

Three questions to check whether the topics above have landed.

1. What mechanism handles late-arriving events in streaming?
2. Which language is primarily associated with Neo4j?
3. What does exactly-once processing guarantee?