Bird
0
0

You want to design a Bigtable schema for IoT sensor data that arrives every second from thousands of devices. Which approach best supports efficient queries for recent data per device?

hard📝 Best Practice Q15 of 15
GCP - Cloud Firestore and Bigtable
You want to design a Bigtable schema for IoT sensor data that arrives every second from thousands of devices. Which approach best supports efficient queries for recent data per device?
AUse row keys as <code>deviceID#reversed-timestamp</code> to keep recent data first and group by device.
BUse row keys as <code>timestamp#deviceID</code> to sort by time globally.
CStore all data in a single row per device with columns for each timestamp.
DUse random UUIDs as row keys to distribute load evenly.
Step-by-Step Solution
Solution:
  1. Step 1: Consider query pattern for recent data per device

    Queries often request recent data, so sorting recent timestamps first helps.
  2. Step 2: Use reversed timestamp in row key

    Reversing timestamp (e.g., max - timestamp) sorts recent data at the top for fast access.
  3. Step 3: Group by deviceID first

    This groups data by device, making queries per device efficient.
  4. Final Answer:

    Use row keys as deviceID#reversed-timestamp to keep recent data first and group by device. -> Option A
  5. Quick Check:

    Reversed timestamp + deviceID = fast recent queries [OK]
Quick Trick: Reverse timestamp in key for recent-first order [OK]
Common Mistakes:
  • Using timestamp first causes hotspots
  • Storing all data in one row causes size limits
  • Random UUID keys prevent efficient range scans

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes