处理cql表中的日期信息

时间:2014-11-06 13:11:28

标签: date cassandra cql

我正在尝试在cassandra中维护我的应用程序的用户日志记录信息。我有以下模型

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

在模型中,我将日期作为分区键,timeuuid作为聚类键,因为我可以查询在给定时间间隔内登录一天的用户列表。 在上面的模型中,我将日期字段作为varchar字段,我觉得这是不合适的。我正在使用TimeUUID,因为它也给了我时间细节。 那么我如何在cql / cassandra中只处理我的日期字段中没有时间信息的日期以解决我的用例?

1 个答案:

答案 0 :(得分:2)

我认为varchar适用于日期字段。为了仅处理没有时间信息的日期,时间序列数据建模入门中的"Time Series Pattern 2"数据模型使用文本类型(它只是varchar的别名)作为其日期字段组合分区键组件。虽然不完全像您的示例,但DataStax Academy的示例与您的数据模型相似,可能会为您提供一些想法或信心。

Time Series Pattern 2 - Partitioning to Limit Row Size

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