To prevent duplicate records with the same epoch time in your database, use the epoch time in milliseconds and apply a unique constraint on the relevant column. This will ensure each record has a distinct timestamp, and the database enforces uniqueness.