# Storing data using Key Value where value is Json/Avro, options for generating the timeuuid

**URL:** https://forum.scylladb.com/t/storing-data-using-key-value-where-value-is-json-avro-options-for-generating-the-timeuuid/1971
**Category:** ScyllaDB
**Tags:** data-model
**Created:** [May 7, 2024, 4:23am UTC](https://forum.scylladb.com/t/storing-data-using-key-value-where-value-is-json-avro-options-for-generating-the-timeuuid/1971 "2024-05-07T04:23:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Guy](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/guy/32/9_2.png) [@Guy](https://forum.scylladb.com/u/Guy)
#### Post date: [May 7, 2024, 4:23am UTC](https://forum.scylladb.com/t/storing-data-using-key-value-where-value-is-json-avro-options-for-generating-the-timeuuid/1971/1 "2024-05-07T04:23:23Z")

</div>

> [@](#):
>
> [**Originally from the User Slack**](https://scylladb-users.slack.com/)
> 
> ![Morten_Bo](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/78f7ca9fc0a270368d1e7f3a0b7aea2714cff58d.jpeg) **@Morten\_Bo:** Hi
> 
> We are looking to use ScyllaDB for storing different types of data in a kind of KeyValue setup where the Value of the Data is JSON/Avro or some other format which can hold multiple records and columns within a single column.
> 
> We utilize a PrimaryKey that looks kind of like this:
> 
> `((datasetid, inserteddate),inserteddatetime,timeuuid)`
> 
> Since in theory different pieces of data can be submitted for a specific datasetid, inserteddate and inserteddatetime I want to utilize the built in currentTimeUUID() function in my inserts on the table, are there any caveats to using the system-generated timeUUID function (as well as currenttimestamp()) when inserting data?
> 
> ![Felipe_Cardeneti_Mendes](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/233a9d524fbc97e39f08633c16b3dd2575d1d1f4.jpeg) **@Felipe\_Cardeneti\_Mendes:** `insertdate` is good for bucketing. But `insertdatetime` + `timeuuid` is redundant. You shouldn’t have any collisions just with `timeuuid` , and you can filter all records ingested within a given `timeuuid` window with the `maxTimeuuid()` and `minTimeuuid()` functions
> 
> ![Morten_Bo](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/78f7ca9fc0a270368d1e7f3a0b7aea2714cff58d.jpeg) **@Morten\_Bo:** I am aware of the redundancy but it is just really nice to be able to visually deduce the timestamp without resorting to using maxtimeuuid() and mintimeuuid() functions. 🙂  
> I might remove inserteddatetime from the PK and simply have it as a regular column on the table
> 
> ![Felipe_Cardeneti_Mendes](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/233a9d524fbc97e39f08633c16b3dd2575d1d1f4.jpeg) **@Felipe\_Cardeneti\_Mendes:** that would be `toTimestamp()` or `toUnixTimestamp()`, not max/min. If your use case is append-only, then you can also rely on `writetime()` on a regular column to retrieve its epoch. Plenty of options to choose from. 🙂
> 
> ![Morten_Bo](https://us1.discourse-cdn.com/flex016/uploads/scylladb/original/1X/78f7ca9fc0a270368d1e7f3a0b7aea2714cff58d.jpeg) **@Morten\_Bo:** Fair.
> 
> My use case is append-only.
> 
> Basically any reading of the data will typically be getting all data for a given dataset in a given timeframe. So can span multiple days and be everything within a day or just a subset of the day. I might play around with different formats.
