Search⌘ K
AI Features

Introduction to Cloud Firestore

Explore the core concepts of Cloud Firestore including its NoSQL database design, hierarchical document-collection model, and flexible fields. Understand how to organize data, handle nested objects, update fields, and use indexing to optimize queries in Flutter and Firebase applications.

To better comprehend what we’re dealing with, let’s delve a little more into Firestore’s structure.

Structure of Firestore

The fact that Cloud Firestore is a NoSQL database is the first important concept to comprehend. But what does this mean? We start from the known (conventional SQL) to the unknown (NoSQL) to better grasp this.

Traditional SQL stores data in a table-like schema. Each table, row, and column has its own set of rules or restrictions on the kind of data that can be stored. For instance, a column for ID can only contain data as an integer, not text. Due to this complexity, we can only store one type of item in each table, and we must add a foreign key to the table in order to associate objects that are related to each other in the database.

However, in Firebase, things are quite different, and data can be stored in a variety of ways, including:

  • Tables

  • Key value store

  • A nested JSON tree

  • A collection of JSON objects

The database is schemaless, meaning that there are no database-level limitations on the types of data that can be stored in the database. The NoSQL database strategy might initially seem strange; however, it offers a number of benefits, some of which are described below:

    ...