- Document Type in NoSQL refers to a model of data that is typically composed of key-value pairs.
- This type is highly flexible and adaptable, making it ideal for many types of data needs.
- For example, in a NoSQL document database, you might have a "User" document that could look something like this:
{
"userId": "123",
"name": "John Doe",
"email": "johndoe@example.com",
"address": {
"street": "123 Main St",
"city": "Springfield",
"state": "IL",
"zip": "62701"
},
"orders": [
{
"orderId": "456",
"product": "Book",
"quantity": "1"
},
{
"orderId": "789",
"product": "DVD",
"quantity": "2"
}
]
}
- This example shows how you can nest objects (like the "address" object) and arrays (like the "orders" array) within a document.
- This allows for complex relationships and hierarchical data structures to be stored in a single document.
- Another advantage of document databases is that they allow you to query and search within these nested structures.