Reputation: 20136
Assuming the following table, is it possible to easily query the most recent items added to the table?
create table messages(
person_uuid uuid,
uuid timeuuid,
message text);
The primary purpose of this table is to hold a list of messages sent to a particular user, but there is also a need to show an RSS feed of all most recent users, ie, something like:
select person_uuid, message from messages
order by uuid
limit 30;
Upvotes: 1
Views: 1135
Reputation: 8812
You need to use Compound Primary Key to be able to sort and order by date.
CREATE TABLE messages(
person_uuid uuid,
date timeuuid,
message text,
PRIMARY KEY(person_uuid,date)
);
Then you can do
SELECT * FROM messages WHERE person_uuid=xxx ORDER BY date DESC LIMIT 20;
Upvotes: 3