The MongoDB docs show an example of a one to many relationship...
(Abbreviated...)
Model One-to-Many Relationships with Document References
// Publisher. { _id: "oreilly", name: "O'Reilly Media", } // Book. { _id: 123456789, title: "MongoDB: The Definitive Guide", publisher_id: "oreilly" } // Book. { _id: 234567890, title: "50 Tips and Tricks for MongoDB Developer", publisher_id: "oreilly" }
Why is the publisher _id
a logical, human-readable name while the book _id
s appear to be generated surrogate keys?
Wouldn't all _id
s be generated values?
Is it conventional in MongoDB to sometimes use the data itself as a unique key and sometimes not?
If so, when do we use ordinary names ("mary", "joe", "exxon"), and when do we prefer generated values?