How to create a composite row key in GridDB using NewSQL?
I am creating a collection container for storing thermostat data for multiple devices. I want to have the composite key on device_id and device_ts. I wanted to use a timeseries but it does not allow multiple keys. But even when using it with a collection container I am unable to add a composite key. Please let me know the syntax for adding a composite row key in GridDB using SQL. I found a link but its using Java programming: https://www.toshiba-sol.co.jp/en/pro/griddb/docs-en/v5/GridDB_ProgrammingGuide.html#handling-composite-row-keys-1
Current syntax used but gives error:
CREATE TABLE thermostat_data (
device_ts TIMESTAMP NOT NULL,
device_id STRING NOT NULL,
temperature DOUBLE,
humidity DOUBLE,
target_temperature DOUBLE,
status STRING,
PRIMARY KEY (device_id, device_ts)
) WITH (
expiration_type='PARTITION',
expiration_time=30,
expiration_time_unit='DAY'
) PARTITION BY RANGE (device_ts) EVERY (1, DAY);
The error is
Execute SQL failed (reason=CREATE TABLE failed (reason=Invalid primary key column definition)
I referred to the doc link https://griddb.org/docs-en/manuals/GridDB_SQL_Reference.html#create-table and used the same syntax for primary key but still it failed:
Syntax provided in the link: CREATE TABLE [IF NOT EXISTS] table_name ( column definition [, column definition …] [, PRIMARY KEY(column name [, …])] ) [WITH (property_key=property_value)] PARTITION BY HASH (column_name_of_partitioning_key) PARTITIONS division_count;