Aarish Ramesh
Aarish Ramesh

Reputation: 7033

Handling date information in cql table

I am trying to maintain the user logging information for my application in cassandra. I have the following model for it

Create table LoggingInfo(date varchar, timeoflogging timeuuid, username varchar, primary key(date, timeoflogging))

In the model, I have date as the partition key and timeuuid as the clustering key as i can query the list of users who have logged in for a day between the given time interval. In the above model, I have the date field as a varchar field which i feel is not appropriate. I am using TimeUUID as it gives me the time detail also. So how i do about handling only dates without time information for my date field in cql/cassandra for solving my usecase?

Upvotes: 2

Views: 2249

Answers (1)

catpaws
catpaws

Reputation: 2283

I think varchar is ok for the date field. For handling only dates without time information, the "Time Series Pattern 2" data model in Getting Started with Time Series Data Modeling uses the text type, which is just an alias for varchar, for its date field composite partition key component. Although not exactly like your example, the example from DataStax Academy is similar and might give you some ideas for or confidence in your data model.

Time Series Pattern 2 - Partitioning to Limit Row Size

Continued: Time Series Pattern 2 example (insert and select)

Upvotes: 3

Related Questions