Reputation: 903
Bit new to Mongodb, have a question on how to store data properly.
I'm making a domain search / history POC, and unsure how to store data. If it was mySQL I'd have the following tables
Domain - Domain name, and current status Domain_Updates - Foreign key to Domain, would store the whois information
{
domain: 'blah.com',
status: 'registered',
updates: [
{
owner: 'john smith',
status: 'expiration',
date: somedategoeshere
},
{
status: 'available',
date:'somedategoeshere'
}
]
}
Would this format of MongoDB last if there were hundreds, or thousands of updates per domain?
Upvotes: 0
Views: 270
Reputation: 1131
Depends on if you wish to search through the updates field quickly. . . are you planning to index it? If you are, the entirety of the updates[] array ends up in the index.
Multikey Index MongoDB uses multikey indexes to index the content stored in arrays.
If you index a field that holds an array value, MongoDB creates separate index entries for every element of the array. These multikey indexes allow queries to select documents that contain arrays by matching on element or elements of the arrays. MongoDB automatically determines whether to create a multikey index if the indexed field contains an array value; you do not need to explicitly specify the multikey type
Source: http://docs.mongodb.org/manual/core/indexes-introduction/
If you're interested in flatter indexing (probably) then you'd be best served injecting a domain_key into the update document and store them in a separate collection.
Upvotes: 1