Dear readers of our blog, we'd like to recommend you to visit the main page of our website, where you can learn about our product SQLS*Plus and its advantages.
 
SQLS*Plus - best SQL Server command line reporting and automation tool! SQLS*Plus is several orders of magnitude better than SQL Server sqlcmd and osql command line tools.
 

REQUEST COMPLIMENTARY SQLS*PLUS LICENCE

Enteros UpBeat offers a patented database performance management SaaS platform. It proactively identifies root causes of complex revenue-impacting database performance issues across a growing number of RDBMS, NoSQL, and deep/machine learning database platforms. We support Oracle, SQL Server, IBM DB2, MongoDB, Casandra, MySQL, Amazon Aurora, and other database systems.

MongoDB: Working with databases. Database device.

14 September 2020

Preamble

The whole model of the database device in MongoDB can be presented as follows:

model of the database device in MongoDB

If in the relational databases the contents are tables, then in the working with  databases consists of collections.

Each collection has its own unique name – an arbitrary identifier consisting of no more than 128 different alphanumeric characters and an underscore.

In contrast to relational databases, MongoDB does not use a tabular device with a clearly defined number of columns and data types. MongoDB is a document-oriented system in which the central concept is a document.

A document may be represented as an object that stores some information. In a sense, it is similar to rows in relational subd, where rows store information about a single element. For example, it is a typical document:

{
"name": "Bill",
"surname": "Gates",
"age": "48",
"company": {
"name" : "microsoft",
"year" : "1974",
"price" : "300000"
}
}

The document represents a set of key-value pairs. For example, in the expression “name”: “Bill” name represents the key, and Bill – the value.

Keys represent rows. Values may differ by the type of data. In this case, almost all values also represent string type, and only one key (company) refers to a separate object. The following types of values are available in total:

  • String: string data type, as in the above example (UTF-8 encoding is used for strings)
  • Array: data type for storing element arrays
  • Binary data: type for storing data in binary format
  • Boolean: A boolean data type that stores logical TRUE or FALSE values, for example {“married”: FALSE}.
  • Date: stores the date in Unix time format
  • Double: numeric data type for storing floating-point numbers
  • Integer: used to store integer values, for example {“age”: 29}.
  • JavaScript: data type for storing javascript code
  • Min key/Max key: used to compare values with the smallest/largest BSON elements
  • Null: data type for storing the Null value
  • Object: string data type, as in the above example
  • ObjectID: data type for storing id document
  • Regular: used to store regular expressions
  • Symbol: data type, identical to a string. It is used mainly for those languages, which have special characters.
  • Timestamp: used to store time

Unlike strings, documents may contain heterogeneous information.

For example, next to a document described above, one collection may contain another object, for example:

{
"name": "Tom",
"birthday": "1985.06.28",
"place" : "Berlin",
"languages" :[
"english",
"german",
"spanish"
]
}

It would seem different objects except for individual properties, but all of them may be in the same collection.

A couple of other important comments: in MongoDB queries are case sensitive and have strict typing. In other words, the next two documents will not be identical:

{"age" : "28" }
{"age" : 28}

If in the first case the age key is defined as a string value, in the second case the value is a number.

Document Identifier

For each document in MongoDB, there is a unique identifier called _id. When a document is added to the collection, this identifier is automatically created. However, the developer can explicitly specify the identifier himself, rather than relying on the automatically generated ones by specifying the corresponding key and its value in the document.

This field shall have a unique value within the collection. And if we try to add two documents with the same identifier to the collection, only one of them will be added, and when we add the second one we get an error.

If the identifier is not specified explicitly, MongoDB creates a special binary value with the size of 12 bytes. This value consists of several segments: the value of timestamp type with the size of 4 bytes, the machine identifier with 3 bytes, the process identifier with 2 bytes, and the counter with 3 bytes.

Thus, the first 9 bytes guarantee uniqueness among other machines, which may be replicas of the database. And the next 3 bytes guarantee uniqueness within one second for one process. Such a model of building an identifier ensures with a high probability that it will have a unique value because it allows you to create up to 16 777 216 unique ObjectId objects per second for one process.

Working with databases

About Enteros

IT organizations routinely spend days and weeks troubleshooting production database performance issues across multitudes of critical business systems. Fast and reliable resolution of database performance problems by Enteros enables businesses to generate and save millions of direct revenue, minimize waste of employees’ productivity, reduce the number of licenses, servers, and cloud resources and maximize the productivity of the application, database, and IT operations teams.

 
Tags: , , ,

MORE NEWS

 

Preamble​​NoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...

Preamble​​MongoDB Conditional operators specify a condition to which the value of the document field shall correspond.Comparison Query Operators $eq...

5 Database management trends impacting database administrationIn the realm of database management systems, moreover half (52%) of your competitors feel...

The data type is defined as the type of data that any column or variable can store in MS SQL Server. What is the data type? When you create any table or...

Preamble​​MS SQL Server is a client-server architecture. MS SQL Server process starts with the client application sending a query.SQL Server accepts,...

First the basics: what is the master/slave?One database server (“master”) responds and can do anything. A lot of other database servers store copies of all...

Preamble​​Atom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to...

Preamble​​MongoDB recently introduced its new aggregation structure. This structure provides a simpler solution for calculating aggregated values rather...

FlexibilityOne of the most advertised features of MongoDB is its flexibility.  Flexibility, however, is a double-edged sword. More flexibility means more...

Preamble​​SQLShell is a cross-platform command-line tool for SQL, similar to psql for PostgreSQL or MySQL command-line tool for MySQL.Why use it?If you...

Preamble​​Writing an application on top of the framework on top of the driver on top of the database is a bit like a game on the phone: you say “insert...

Preamble​​Oracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...

Preamble​​IBM pureXML, a proprietary XML database built on a relational mechanism (designed for puns) that offers both relational ( SQL / XML ) and...

  What is PostgreSQL array? In PostgreSQL we can define a column as an array of valid data types. The data type can be built-in, custom or enumerated....

Preamble​​If you are a Linux sysadmin or developer, there comes a time when you need to manage an Oracle database that can work in your environment.In this...

Preamble​​Starting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...