Single Collection Database Design

Working on a project where I want to have a single collection for all my documents. I have 4 different document types but I don’t know how to properly define them in a single schema.

I created a cluster already. I pulled the project files from realm into my project folder using realm-cli. In …/data_sources/mongodb-atlas/schemas/ I have relationships.json, rules.json, schema.json. As described above I want to define multiple document types in the schema.json folder. For example, I have:

{
    "title": "documentA",
    "bsonType": "object",
    "required": [
        "_id",
    ],
    "properties": {
        "_id": {"bsonType": "objectId"},
        "name": {"bsonType": "string"}
   }
}

How can I add another another document type to this file (i.e. “title”: “documentB”)?
Additionally, for AWS Dynaomdb single table design is sort of the standard. Is that the same case here or is there performance pros/cons to be aware of here?

I’m not sure why you want to have all the documents in a single collection but I would strongly recommend against it. It is not a good design pattern. It has many downsides and I can’t think of a single advantage.

Asya

3 Likes

It is my understanding for AWS that single design with dynamoDB is more efficient. I was curious if that was the case here. I ended up doing multiple collections anyways. Thanks for the response!

1 Like