← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

SQL-heavy Data Engineer screen at Meta, four questions all centered on a library database schema. Nothing behavioral, just back-to-back query writing with some tricky aggregation logic thrown in.

Questions Asked (4)

Q1

Given a library database, write a SQL query to count books that are currently checked out and in good condition.

Data Modeling
Author's notes

Warm-up question, felt fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and the exact meaning of 'currently checked out' and 'good condition'. Then write a query that joins the books table with the loans table, filters for active loans and condition = 'good', and counts distinct books.

Pro tip: Mention that you would confirm the definition of 'good condition' with the interviewer, as it might be a specific enum value or a range, and consider using COUNT(DISTINCT book_id) to avoid double-counting if a book has multiple active loans.

1. Clarify requirements and schema

Ask about the table structures, the meaning of 'currently checked out' (e.g., return_date IS NULL), and how 'good condition' is represented (e.g., condition = 'good').

2. Identify relevant tables and join keys

Determine which tables are needed (e.g., Books and Loans) and how they relate (e.g., Books.book_id = Loans.book_id).

3. Write the query with filters

Construct a SQL query that joins the tables, filters for active loans and good condition, and counts the books.

4. Consider edge cases and optimizations

Think about duplicates, NULL values, and indexing; use COUNT(DISTINCT) if necessary and mention potential performance improvements.

5. Explain and validate the query

Walk through the query logic, explain each clause, and suggest how to test it with sample data.

Key Points to Mention

  • Use of JOIN to combine books and loans tables
  • Filtering with WHERE return_date IS NULL for currently checked out
  • Filtering with condition = 'good' (or appropriate condition check)
  • Using COUNT(DISTINCT book_id) to avoid duplicates
  • Handling NULLs and ensuring correct join type (INNER JOIN)
  • Considering indexes on foreign keys and condition columns for performance

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Among the checked-out, good-condition books from the previous query, what percentage have been renewed more than twice? Use that same subset as the denominator.

Data ModelingProduct Analytics & Metrics
Author's notes

This is where I slowed down.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clearly define the subset from the previous query: books that are checked out and in good condition. Then, within that subset, count how many have been renewed more than twice, and divide by the total number of books in the subset to get the percentage.

Pro tip: Always clarify ambiguous terms like 'renewed more than twice' (does it mean >2 or >=2?) and ensure the denominator is exactly the same subset as before to maintain consistency.

1. Reconstruct the subset

Identify the exact criteria from the previous query: checked-out status and good condition. Apply these filters to the books dataset to get the denominator.

2. Define 'renewed more than twice'

Clarify whether 'more than twice' means strictly greater than 2 (i.e., 3 or more) or at least 2. This affects the count.

3. Count qualifying books

Within the subset, count how many books have a renewal count that meets the defined threshold.

4. Calculate percentage

Divide the count from step 3 by the total count of the subset (denominator) and multiply by 100 to get the percentage.

5. Validate and present

Double-check that the denominator matches the previous query's subset and that the calculation is correct. Present the result clearly.

Key Points to Mention

  • Importance of consistent filtering criteria between numerator and denominator
  • Definition of 'renewed more than twice' and potential ambiguity
  • Use of SQL or data manipulation tools to perform the calculation
  • Ensuring data quality (e.g., handling nulls or missing renewal counts)
  • Communicating assumptions clearly when presenting the answer

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Return the top 3 book titles (or IDs) that have more than 10 copies and the longest cumulative lending time summed across all their loans.

Data ModelingAlgorithms & Data Structures
Author's notes

Group by book, sum the loan durations, filter where copy count exceeds 10, order descending, limit 3.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the schema and define cumulative lending time as the sum of loan durations per book. Then filter books with more than 10 copies, aggregate total lending time per book, sort descending, and return the top 3 titles or IDs.

Pro tip: Mention that you would verify the definition of 'lending time' (e.g., return date minus checkout date) and handle edge cases like unreturned loans or missing dates, showing attention to data quality.

1. Clarify schema and definitions

Identify the relevant tables (e.g., Books, Copies, Loans) and confirm how to compute lending time (e.g., DATEDIFF between checkout and return).

2. Filter books by copy count

Count copies per book and keep only those with more than 10 copies, using a subquery or HAVING clause.

3. Aggregate lending time per book

Join the filtered books with loans, sum the lending durations, and group by book ID or title.

4. Sort and limit results

Order the aggregated results by total lending time descending and select the top 3.

5. Optimize and validate

Consider indexing, discuss query performance, and validate results with edge cases (e.g., books with no loans).

Key Points to Mention

  • SQL aggregation with GROUP BY and HAVING for filtering after grouping
  • Joins between books, copies, and loans tables
  • Handling NULL return dates for ongoing loans
  • Indexing on foreign keys and date columns for performance
  • Using ORDER BY with LIMIT to get top results
  • Clarifying ambiguous requirements with the interviewer

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Find the member and referrer pair with the largest difference in the number of reservations each has made, and return that pair along with the difference.

Data ModelingAlgorithms & Data Structures
Author's notes

Hardest one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the schema and whether 'member' and 'referrer' are distinct roles or the same entity, then compute reservation counts per member and join with referral relationships to find the maximum absolute difference. Use a self-join or window function to efficiently compare counts for each referrer-referrer pair.

Pro tip: Discuss handling ties and edge cases like members with zero reservations or missing referrers, and mention that the difference should be absolute unless specified otherwise.

1. Clarify Requirements and Schema

Ask about the table structures: members, referrals (who referred whom), and reservations. Confirm if 'member' and 'referrer' are both members and if the difference is absolute.

2. Compute Reservation Counts

Aggregate reservations per member to get a count for each member, including those with zero reservations if they are in the members table.

3. Join Referral Relationships with Counts

Join the referral table with the reservation counts for both the member and the referrer to bring their counts into the same row.

4. Calculate Difference and Find Maximum

Compute the absolute difference between the two counts, then order by difference descending and limit to 1 (or use a window function) to get the pair with the largest difference.

5. Handle Ties and Edge Cases

Decide how to handle ties (e.g., return all pairs or pick one arbitrarily) and consider members with no referrer or no reservations.

Key Points to Mention

  • Use of LEFT JOIN to include members with zero reservations
  • Aggregation with COUNT and GROUP BY to get reservation counts
  • Self-join or joining the referral table twice to get both member and referrer counts
  • Absolute difference calculation using ABS()
  • Ordering and limiting results, or using ROW_NUMBER() for ties
  • Indexing considerations for performance on large datasets

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.