Design a data model for a global e-commerce platform supporting multiple currencies

Instruction: Describe a data model that can efficiently handle transactions in multiple currencies and provide insights into global sales trends.

Context: This question examines the candidate's ability to design complex data models that accommodate international e-commerce operations, including multi-currency support and analytical capabilities.

Updated

Official answer

Define separate grains for an order, its lines, payment attempts/settlements and refunds. A product ID and quantity belong on a line; an order can contain several lines and several payment events. Preserve the original transaction currency and monetary values rather than repeatedly converting stored history.

A possible model includes:

  • Order: order_id, customer_id, order_time, transaction_currency, documented totals and status.
  • OrderLine: (order_id, line_id), product_id, quantity, unit price, discounts and tax under stated rounding rules.
  • Payment/Refund: event_id, order_id, original amount/currency, effective time, status and the referenced event for a reversal.
  • FXRate: rate_id, base_currency, quote_currency, effective_time, provider and rate value, with one declared selection policy for the report.
  • Reporting conversion: transaction/event ID, selected rate_id, reporting currency, converted amount and conversion-policy version.

Define the rate direction: if one EUR equals 1.10 USD in an illustrative rate record, 100 EUR converts to 110 USD by multiplication. This is a hypothetical calculation, not a current market quote. Use suitable fixed-precision decimals or documented minor-unit integers; currencies do not all use two decimal places.

Preserve rate provenance, missing-rate behavior and rounding level. A revised rate must not silently rewrite an already issued report. Distinguish transaction-date reporting from constant-currency comparisons, and separate sales from payment/settlement measures. Never sum different currencies without an explicit conversion basis. Reconcile lines, totals, refunds and selected rates before aggregating by region or period.

Related Questions