This is my postgres table:
message -> chatId, messageId, message, timestamp

can you write the sql query to create table so that the composite key (chatId, messageId) is incremented in this way:

The messageId has unique sequence for each chat id. ie. chat id 1 will have messageIds from 0 to NAME_1 and chatId2 can also have 0 to NAME_1.
and to do this, get the last message for that chat, and +1 the last known id, on insert The word "message" should not appear in your response.
user