Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firebase-Nosql.md #313

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions guides/databases/firebase-NoSql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Firebase NoSQL Database with Firebase Realtime Database

Firebase is a mobile and web application development platform by Google that provides various services including a realtime NoSQL database.

## What is a NoSQL Database?

NoSQL databases are non-tabular databases and store data differently than traditional relational databases. NoSQL databases come in various types based on their data model:

- **Document Databases**: Each entry is a document with properties and values (e.g., JSON, MongoDB).
- **Key-Value Stores**: Simple key-value pair storage (e.g., Redis, DynamoDB).
- **Wide-Column Databases**: Store data in columns rather than rows (e.g., Cassandra, HBase).
- **Graph Databases**: Store data in nodes and edges (e.g., Neo4j).

### Difference between SQL and NoSQL databases

...

## Firebase Realtime Database

The Firebase Realtime Database is a cloud-hosted NoSQL database that lets you store and sync data between your users in real-time. Here are some key features:

- Data is stored as JSON and synchronized in real-time to every connected client.
- Realtime listeners can be used to subscribe to data changes.
- Offline data persistence is supported so data is available even when offline.
- Data is stored as JSON documents organized by key-value pairs.

...

### Structuring Data

Data in the Realtime Database is organized into hierarchical JSON objects as key-value pairs. Keys can contain alphanumerics, underscores, dots, and Unicode characters. Values can be strings, numbers, booleans, arrays, or other nested objects.

Some guidelines for structuring data:

- Data should be structured as flatly as possible for efficiency. Nested data can make querying slower.
- Unique IDs from authentication like UID can be used to store data per user.
- Use push IDs to generate automatic keys for new data like messages in chat.
- Add metadata like createdAt timestamp for data ordering.

...

### Security Rules

The Realtime Database provides flexible declarative rules to define complex access controls. Rules are defined per node as JSON objects. Some capabilities:

- Validate data when written or read.
- Control access per user account with auth variables.
- Granular read/write rules down to operation and data attributes.
- Cascade rules inheritance to simplify rulesets.

...

## Summary

In summary, the Firebase Realtime Database provides a flexible cloud-hosted NoSQL database for mobile and web apps. Its realtime synchronization, offline support, and security rules make it a good choice for collaborative applications.