NoSQL Model Google Professional Data Engineer GCP

  1. Home
  2. NoSQL Model Google Professional Data Engineer GCP

In this, we will learn the concepts of NoSQL Model in GCP.

NoSQL models

  • Key Value Store – schema-less , key points to an specific item but lack of consistency
  • Document Store – Similar to key value stores, documents store data in encoding (XML/JSON)
  • Column Store – Data stored in columns, comprised of multiple column families which logically group specific columns. A key identify and point to a number of columns, each column store in separate file and has tuples of names-values, ordered and comma-separated.
  • Graph Base – It is a directed graph structure and consists of edges and nodes. represents pack of objects, connected by links.

GCP document-oriented database:

  • Firestore is a document-oriented database that runs on top of NoSQL.
  • There are no tables or rows in this database, unlike a SQL database. Data is instead stored in documents that are arranged into collections. A collection of key-value pairs may be found in each document. Firestore is designed to hold enormous amounts of tiny documents.
  • Collections must be used to hold all papers. Subcollections and nested objects, both of which can include simple fields like strings or complicated objects like lists, can be found in documents. In Firestore, collections and documents are formed implicitly.
  • Simply said, data may be assigned to a document within a collection. Firestore builds the collection or document if it does not exist.

Documents

The document is the storage unit in Firestore. A document is a simple record with fields that correspond to values. A name assign to each document.

The following is an example of a document describing a user alovelace:

  • class alovelacefirst : "Ada"
    last : "Lovelace"
    born : 1815

Maps are hierarchical, complex items in a document. For example, you could use a map to organise the user’s name from the previous example:

  • class alovelacename :
        first : "Ada"
        last : "Lovelace"
    born : 1815

You’ll note that the papers resemble JSON. They are, in reality, essentially the same. Although there are significant distinctions (for example, documents enable more data types and restrict to 1 MB in size), documents may treat as lightweight JSON records in general.

Collections

nosql model example

Documents are stored in collections, which are nothing more than storage containers for documents. You might, for example, have a users collection that contains all of your different users, each of whom represents by a document:

collections_bookmark users

class alovelacefirst : "Ada"
last : "Lovelace"
born : 1815

class aturingfirst : "Alan"
last : "Turing"
born : 1912

Hierarchical Data

Consider a chat app with messages and chat groups to see how hierarchical data structures function in Firestore.

You may save different chat rooms in a collection named rooms:

collections_bookmark rooms

class roomAname : "my chat room"

class roomB...

Decide how you’ll save your messages now that you’ve had chat rooms. It’s possible that you won’t want to save them in the chat room’s document. Firestore documents should be light, and a chat room might have a big amount of messages. However, as subcollections, you may construct more collections within your chat room’s document.

Reference: Check here

Menu