quinta-feira, 2 de fevereiro de 2023

[Mongo DB] Introduction to the Document Model

Hello all

One more step on Mongo DB University.

Today, I'm learning about MongoDB and the Document Model.

The main points of this module are: 

Overall, we can say that Mongo DB:
    - It's a General-Purpose Document Database.
    - By default, Mongo DB supports a flexible schema model and a polymorphic data. 
    - This allows us to store documents with different structures in the same collection.

The main advantages to use Mongo DB: 
    1) Documents offer a flexible and developer-friendly way to work with data.
    2) Easier and faster to plan how application data will correspond to data store in the database.
    3) Modal data of any shape or structure.
    4) Documents can model everything:
            Key-values pairs
    Geospatial indexes
    Time series
    Graph data
    and more
    5) Use one format for any application.
    6) Easy connect - Provide drivers in all major programming languages.
Basically, you can use Mongo DB in any application:
    Content management
    IoT and time series data
    Trading and payments
    Mobile Apps
    Real-time analytics and AI
Your main features are:
    Speed of development
    High levels of data privacy
And finally, we have 3 Key term:
    Document - The basic unit of data on Mongo DB.
    Collection - A group of those documents. Documents in a collection are tipically similar they don't have the exact same structure, because Mongo DB has a flexible schema model.

    Database - A container for our collections. 

The Document model.

We can say many things about The Document Model, but this is the summary:
    - On Mongo DB, data is organized into documents, collections, and databases.
    - Mongo DB stores data in structures known as documents
    - Mongo DB structures data in documents, which are similar to JSON Objects
    - Documents are stored in BSON, which supports a large range of data types, including all JSON data types, dates, numbers, and ObjectIds.
    - Mongo DB displayed the data documents in JSON format, but they're stored in the database in a format called BSON (Binary JSON).
    - BSON is an extension of JSON and providing additional features 
    - BSON add support for additional data types unavailable in Standard JSON 
    - Every document requires an "_id" field, which acts as a primary key. 
    - The "_id" is a required field in every MongoDB document, but it's not a data type. If an inserted document does not include an "_id" field, MongoDB will automatically create the "_id" field and populate it with a value of type ObjectId.
    - Documents can contain different fields and fields may contains different data types.
    - If you want to have more control over the structure and content, we can add optional schema validation rules to set constraints on the structure of documents. 
Some Datatypes that you have on Mongo DB:
    All the JSON datatypes
ObjectIDs - It's a special data type used in Mongo DB to create unique identified.
    If you want moder information, click here.

Finally, an example to the syntax for a MongoDB document:

"key": value,
"key": value,
"key": value
     "codigo": 2, 
     "trilogy": "Harry Potter", 
     "sequence": "Harry Potter and the Chamber of Secrets", 
     "year": "2002",
     "points": ["The first movie of trilogy", "I watched the movie at the cinema"]

So that's it for today, folks.

I hope this helps you!


Nenhum comentário:

Postar um comentário

Isso te ajudou? Comente...

Postagem em destaque

[ORACLE] Increasing the number of cores in a virtualized Oracle Database Appliance.

Hello everyone. How are you going? Today, I'll show you the process to increase the number of cores in a virtualized ODA HA X7-2. Import...