← Amazon Interview Insights

Amazon·Data Scientist·Onsite - System Design / Architecture·Senior

Senior
Apr 2026

Summary

Amazon data scientist loop with a heavy focus on data modeling and SQL. The whole session felt like a database design exam more than anything else. Walked out unsure if I'd been thorough enough on the warehouse side.

Questions Asked (6)

Q1

Design a normalized OLTP schema for a university domain covering Students, Courses, Departments, Instructors, and Enrollments. Include primary and foreign keys, constraints like preventing a student from enrolling in two sections of the same course in the same term, a controlled grade value set, and the indexes you would add and why.

Data ModelingTechnical Trade-offs
Author's notes

I went straight to the Enrollment table and started listing columns before thinking about the constraint properly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by identifying the core entities and their relationships, then normalize to 3NF to eliminate redundancy. Define primary keys, foreign keys, and constraints to enforce business rules, and finally add indexes to optimize common query patterns. Explain trade-offs between normalization and performance, especially for OLTP workloads.

Pro tip: Demonstrate awareness of real-world constraints: mention that while strict normalization is ideal, denormalization might be considered for read-heavy analytics, but for OLTP, prioritize data integrity and write efficiency. Also, discuss how to handle the 'same course, same term' constraint using a composite unique key or a check constraint with a subquery.

1. Identify Entities and Relationships

List all entities (Students, Courses, Departments, Instructors, Enrollments) and define their relationships (e.g., a student enrolls in multiple courses, a course belongs to a department, an instructor teaches a course).

2. Design Tables and Normalize

Create tables for each entity with appropriate attributes, ensuring 3NF. Use surrogate or natural primary keys, and add foreign keys to enforce referential integrity.

3. Define Constraints and Business Rules

Implement constraints such as unique composite key on (student_id, course_id, term) to prevent duplicate enrollments in same course/term, and a check constraint or lookup table for grade values.

4. Add Indexes for Performance

Identify frequent query patterns (e.g., enrollments by student, courses by department) and create indexes on foreign keys and columns used in WHERE, JOIN, and ORDER BY clauses.

5. Discuss Trade-offs and Scalability

Explain how normalization ensures data integrity but may require joins; indexes speed reads but slow writes. Mention partitioning or other techniques for large-scale OLTP.

Key Points to Mention

  • Use of composite unique key on (student_id, course_id, term) to prevent duplicate enrollments in same course/term.
  • Grade value set enforced via CHECK constraint or a reference table with foreign key.
  • Indexes on foreign keys (e.g., enrollments.student_id, enrollments.course_id) to speed up joins and lookups.
  • Normalization to 3NF to eliminate redundancy and update anomalies.
  • Consideration of surrogate keys vs natural keys for primary keys.
  • Trade-off between normalization and performance, and how indexes mitigate join costs.

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

Q2

Design a star schema data warehouse for enrollment analytics. Define the grain of FactEnrollment, the measures it should carry, the dimension tables, surrogate key strategy, and how you would implement SCD Type 2 on the student dimension to track major changes with point-in-time correctness.

Data ModelingSystem Design
Author's notes

SCD Type 2 is one of those things I know conceptually but always stumble explaining live.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the business questions and analytics requirements to define the grain of FactEnrollment. Then design the star schema with appropriate dimensions, surrogate keys, and SCD Type 2 for the student dimension, explaining how point-in-time correctness is achieved. Finally, discuss implementation considerations and trade-offs.

Pro tip: Emphasize that the grain should be the most atomic level possible to allow flexible aggregation, and that SCD Type 2 requires careful handling of surrogate keys and effective dating to ensure accurate historical reporting.

1. Clarify Business Requirements

Ask questions to understand what enrollment metrics are needed, such as counts, trends, and student demographics. Identify the key performance indicators (KPIs) and the level of detail required.

2. Define the Grain of FactEnrollment

Determine the most atomic level of data, such as one row per student per course per term. This ensures flexibility for aggregation and avoids double-counting.

3. Identify Measures and Dimensions

List the additive measures (e.g., enrollment count, credits) and the dimension tables (e.g., Student, Course, Term, Date). Design surrogate keys for each dimension.

4. Implement SCD Type 2 on Student Dimension

Explain how to track changes in student attributes like major by adding new rows with effective dates and current flags. Use surrogate keys to link fact rows to the correct dimension version.

5. Ensure Point-in-Time Correctness

Describe how to join facts to dimensions using the surrogate keys and date ranges to reflect the state at the time of enrollment. Discuss ETL processes to maintain SCD Type 2.

Key Points to Mention

  • Grain: one row per student per course per term (or per enrollment transaction).
  • Measures: enrollment count, credits attempted, tuition amount, etc.
  • Dimensions: Student, Course, Term, Date, Instructor, etc.
  • Surrogate keys: system-generated integers for each dimension row, including SCD Type 2 versions.
  • SCD Type 2: add new row for changes, with effective start/end dates and current flag.
  • Point-in-time correctness: join fact to dimension using surrogate key and ensure the fact's date falls within the dimension row's effective period.

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

Q3

How would you partition and cluster a FactEnrollment table that has over 100 million rows? Justify your choices based on typical query patterns and maintenance considerations.

System DesignTechnical Trade-offs
Author's notes

Felt comfortable here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the query patterns and data characteristics, then propose a partitioning strategy (e.g., range partitioning on enrollment date) and a clustering strategy (e.g., cluster by student_id) that align with those patterns. Justify choices by discussing how they improve performance for common queries and simplify maintenance tasks like data loading and purging.

Pro tip: Mention that partitioning and clustering should be driven by the most frequent and expensive queries, and that you would validate the design with real query plans and performance metrics before full implementation.

1. Understand Query Patterns and Data

Identify the most common queries (e.g., by date range, student, course) and data volume growth. Determine if queries are point lookups, range scans, or aggregations.

2. Choose Partitioning Key

Select a partitioning key that aligns with query filters and maintenance needs. For example, partition by enrollment_date (monthly or yearly) to enable partition pruning and easy archival.

3. Choose Clustering Key

Within each partition, cluster by a column frequently used in filters or joins, such as student_id, to co-locate related rows and speed up point queries.

4. Justify Trade-offs

Explain how the choices improve query performance (e.g., partition pruning, clustered index seeks) and maintenance (e.g., partition switching for data loads, dropping old partitions).

5. Consider Maintenance and Scalability

Discuss how the design handles data growth, index maintenance, and potential skew. Mention monitoring and possible adjustments over time.

Key Points to Mention

  • Partition pruning reduces I/O for date-range queries.
  • Clustering on student_id improves performance for student-centric queries.
  • Partitioning by date simplifies data retention and archival.
  • Clustered indexes can speed up joins and aggregations.
  • Consider partition size to avoid too many small partitions.
  • Regular index maintenance and statistics updates are crucial.

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

Q4

Write a SQL query to find all students who enrolled in both 'CS101' and 'MATH201' during the same term.

Data ModelingAlgorithms & Data Structures
Author's notes

Self-join or two CTEs, I went with two CTEs and an inner join on student_id and term_id.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the schema and then use a self-join or GROUP BY with HAVING to find students enrolled in both courses in the same term. Ensure the query handles duplicates and returns distinct students.

Pro tip: Mention that you would verify the grain of the enrollment table and consider indexing on (student_id, term, course_id) for performance, as Amazon values scalability.

1. Clarify schema and assumptions

Ask about table structure (e.g., enrollments with student_id, course_id, term) and confirm that 'same term' means identical term value. State any assumptions.

2. Choose approach: self-join vs aggregation

Decide between a self-join on student_id and term with course filters, or GROUP BY student_id, term with HAVING COUNT(DISTINCT course_id) = 2 and course IN ('CS101','MATH201').

3. Write the SQL query

Construct the query, ensuring it returns distinct students. For self-join, use aliases and filter each side for the respective course.

4. Handle edge cases and performance

Consider duplicates, NULLs, and indexing. Discuss how the query scales with large data.

5. Test and explain

Walk through a sample dataset to verify correctness and explain the logic clearly.

Key Points to Mention

  • Use of self-join or GROUP BY with HAVING to find intersection
  • Ensuring same term condition is applied
  • Handling duplicates with DISTINCT or COUNT(DISTINCT)
  • Performance considerations: indexing, avoiding unnecessary joins
  • Clarifying schema and assumptions before writing query
  • Testing with sample data to validate logic

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

Q5

For the most recently completed term, write a SQL query returning the top 3 departments ranked by credit-weighted average GPA. Ties should be broken deterministically.

Product Analytics & MetricsData Modeling
Author's notes

This one took me longer than I'd like to admit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, identify the most recently completed term using a subquery or CTE. Then compute the credit-weighted average GPA per department for that term, and rank departments using a deterministic tie-breaker such as department name. Finally, return the top 3 departments.

Pro tip: Explicitly state your assumptions about the data model (e.g., how terms are identified, how credits are stored) and mention that you would validate the query against edge cases like ties or missing data.

1. Identify the most recent term

Use a subquery or CTE to find the maximum term identifier (e.g., MAX(term_id) or MAX(term_date)) from the enrollments or terms table.

2. Compute credit-weighted GPA per department

Join enrollments, courses, and departments, filter for the most recent term, and calculate SUM(grade_points * credits) / SUM(credits) grouped by department.

3. Rank departments with deterministic tie-breaking

Use a window function like RANK() or ROW_NUMBER() with ORDER BY weighted_gpa DESC, department_name ASC to ensure ties are broken consistently.

4. Select top 3 departments

Filter the ranked results to keep only rows where rank <= 3, and return the department name and weighted GPA.

Key Points to Mention

  • Credit-weighted GPA formula: SUM(grade_points * credits) / SUM(credits)
  • Using a subquery or CTE to dynamically find the most recent term
  • Deterministic tie-breaking using an additional column like department name
  • Window functions (RANK, ROW_NUMBER) for ranking
  • Handling NULLs or missing grades appropriately
  • Assumptions about the schema (e.g., tables for students, courses, enrollments, departments)

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

Q6

Compare the trade-offs between OLTP and OLAP database design in this university scenario, and explain when you would choose a snowflake schema over a star schema.

Technical Trade-offsSystem Design
Author's notes

Gave the standard normalization vs denormalization angle.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by contrasting OLTP and OLAP design goals—transactional integrity and speed vs. analytical query performance and historical analysis—using the university scenario to illustrate. Then, explain the star vs. snowflake schema trade-off, focusing on normalization, query complexity, and performance, and conclude with when to choose snowflake over star based on specific requirements.

Pro tip: Tie your answer to Amazon's leadership principles: emphasize customer obsession by choosing the schema that best serves the end-user's query patterns, and insist on the highest standards by acknowledging that the 'right' choice depends on data volume, query complexity, and maintenance trade-offs.

1. Define OLTP and OLAP in the university context

Describe OLTP as handling day-to-day operations like student registration and grade entry, requiring high concurrency and ACID compliance. Describe OLAP as supporting analytical queries like enrollment trends and performance dashboards, optimized for read-heavy, complex aggregations.

2. Compare trade-offs in design

Contrast normalization (OLTP) vs. denormalization (OLAP), row-store vs. column-store, and indexing strategies. Highlight how OLTP prioritizes write efficiency and data integrity, while OLAP prioritizes read speed and analytical flexibility.

3. Explain star and snowflake schemas

Define star schema as a denormalized structure with a central fact table and dimension tables, and snowflake schema as a normalized version where dimensions are split into multiple tables. Mention that star is simpler and faster for queries, while snowflake reduces redundancy and storage.

4. Discuss when to choose snowflake over star

Choose snowflake when dimension tables are large and highly normalized, storage is a concern, or when complex hierarchies require frequent updates. Also consider it when the ETL process can handle the added complexity and query performance is acceptable.

5. Conclude with a recommendation for the university scenario

Recommend a hybrid or context-specific approach: use OLTP for operational systems and OLAP with a star schema for most analytics, but opt for snowflake if the university's data has complex dimensions (e.g., multi-level academic hierarchies) and storage efficiency is critical.

Key Points to Mention

  • OLTP vs. OLAP: ACID vs. BASE, normalized vs. denormalized, row vs. column storage.
  • Star schema: simplicity, fewer joins, faster query performance, but data redundancy.
  • Snowflake schema: reduced redundancy, easier dimension maintenance, but more complex queries and potentially slower performance.
  • Trade-offs: storage cost vs. query speed, ETL complexity, and scalability.
  • Use cases: star for simple, frequent queries; snowflake for complex, hierarchical dimensions and storage optimization.
  • University example: OLTP for student records, OLAP for analyzing enrollment and performance; star for most reports, snowflake if dimensions like 'course' have many levels.

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