#atom

Schema design for non-relational databases

Core Idea: NoSQL data modeling is the process of designing flexible, schema-less data structures optimized for specific access patterns, prioritizing performance and scalability over the normalized structures of relational databases.

Key Elements

// Embedded document approach (one-to-many)
{
  "_id": ObjectId("5f8a716b0b61f835d8a8d5e1"),
  "title": "Introduction to NoSQL",
  "author": {
    "name": "Jane Smith",
    "email": "jane@example.com"
  },
  "comments": [
    {
      "user": "Alex",
      "text": "Great article!",
      "date": ISODate("2023-01-15T08:30:00Z")
    },
    {
      "user": "Sam",
      "text": "Very informative",
      "date": ISODate("2023-01-16T14:22:00Z")
    }
  ]
}

// Reference approach (many-to-many)
// Posts collection
{
  "_id": ObjectId("5f8a716b0b61f835d8a8d5e1"),
  "title": "Introduction to NoSQL",
  "author_id": ObjectId("5f8a716b0b61f835d8a8d5e2"),
  "tags": [ObjectId("5f8a716b0b61f835d8a8d5e3"), ObjectId("5f8a716b0b61f835d8a8d5e4")]
}

Additional Connections

References

  1. MongoDB Data Modeling: https://www.mongodb.com/docs/manual/core/data-modeling-introduction/
  2. NoSQL Distilled (Pramod J. Sadalage and Martin Fowler)

#nosql #databases #data-modeling


Connections:


Sources: