0

I’m on GridDB Cloud (Free). For a TimeSeries container, I want each device to have at most one row per timestamp, i.e., enforce uniqueness on (ts, deviceid).

Schema:

CREATE TABLE TSDB (
  ts TIMESTAMP PRIMARY KEY,   -- row key
  deviceid STRING,
  temperature DOUBLE
) USING TIMESERIES;

Question: Does GridDB TimeSeries support a composite primary key like (ts, deviceid) (or a UNIQUE (ts, deviceid) constraint), or is ts the only allowed row key? If composites aren’t supported, what’s the recommended pattern to enforce one row per device per timestamp (e.g., modeling or indexing approach)?

Environment:

  • GridDB Cloud (Free)
  • SQL console.
4
  • 2
    Based on their information, composite keys are available since version 4.3. Commented Oct 4 at 18:46
  • @PaulT. That's collections only, not time series Commented Oct 4 at 19:51
  • 1
    Based on reading the documentation (which you could also do) I think if you need this protection at database level (do you? Your app could enforce this?) you would need a collections container with a timestamp as part of the PK. Commented Oct 4 at 22:35
  • 1
    And actually, does it really matter if you log the same reading twice? Just filter out duplicates when you retrieve the data? Commented Oct 4 at 22:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.