I am a java programmer and I want to use MongoDB in my project. I know that MongoDB is a document database but is there any way to store more fields for a record in this db ?
For example I have a table with 4 attributes (i.e. columns) name address age and dob so can I use or convert this structure to fit into MongoDB ?
Of course.
MongoDB is a document-based database management system. If you are familiar with the JSON format, Mongo stores data in a very similar manner. For example, a sample document in a Mongo database may look like this:
Person {
Name:
{
First : "John"
Last : "Smith"
}
Address :
{
City : "Chicago"
State : "Illinois"
Street : "30 S. Michigan Avenue"
}
}
As you can see Mongo supports nested fields, so a particular field can contain one or more attributes. It is not key/value per se, as it is possible to nest document ad infinitum. Beware, however, that not all documents in a collection have to have the same structure. This is Mongo's biggest strength, but it can turn around and bite you if you're not careful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With