Setting UNIQUE constraint on TIMESTAMP (WITH TIME ZONE) I want to scrape a table from a website and synchronize the data into my own database i.o. to detect whenever there is a new entry available. The table has a timestamp column which tells me when the new record was created.
However, I have different tables for multiple objects so in order to know if there is a new entry, I'd need a unique-constraint on (object_id, timestamp):
object_id  | timestamp           | value
------------------------------------------
1          | 2021-01-01 00:00:00 | 100      &lt;--|
1          | 2021-01-02 00:00:00 | 101         | error: have an
1          | 2021-01-03 00:00:00 | 102         | equal timestamp
1          | 2021-01-01 00:00:00 | 103      &lt;--| 
2          | 2021-01-10 00:00:00 | 1002
2          | 2021-01-12 00:00:00 | 1003

It feels a  bit odd to have such a unique-constraint so I was wondering if this is the only (or best) way I could do this?
There is nothing wrong with having a multi-column constraint:
ALTER TABLE mytab ADD PRIMARY KEY (object_id, timestamp);

The column order does not matter for the constraint, but if you more often search by timestamp alone, put that column first.