3
It is possible that the same ObjectId
is generated for a document in two different collections in the same database?
3
It is possible that the same ObjectId
is generated for a document in two different collections in the same database?
5
According to official documentation, Objectids are small, "probably" unique, fast-generation and ordered values.
This "probably" documentation would be more related to the impossibility of ensuring that these ids can never be repeated, mainly by the nature of Mongodb’s architecture in facilitating distributed databases. But I haven’t come across any reports of use that would have generated a disability.
Still from documentation Objectid values are 12 bytes long, consisting of:
In this way it is possible to verify why the composition of the Objectid makes it extremely difficult a duplicity, it is not infallible, but it is very rare.
The documentation further describes that the BSON format itself is little-endian, the timestamp and counter values are big-endian, with the most significant bytes appearing first in the byte sequence.
To check the official documentation Mongodb Objectid - BSON Types
0
The Objectid generates a unique value, consisting of:
More information on: https://www.mongodb.com/blog/post/generating-globally-unique-identifiers-for-use-with-mongodb#:~:text=Objectid%20is%20automatically%20generated%20by,to%20sort%20by%20creation%20time.
and
Browser other questions tagged database mongodb nosql
You are not signed in. Login or sign up in order to post.
You want to know if you can duplicate or if it’s likely to happen by a system failure?
– Cristiano Gilberto João
For a failure. Can create the business rule from this assumption (duplicity possible or not).
– Gabriel Ribeiro
Right! The best approach would be not to consider the assumption of duplicity. Even because the possibility of this happening is extremely remote, almost never going to happen. To happen this is the same as to repeat the Datetime. Improbable!!!
– Cristiano Gilberto João