Realtime Database vs FirestoreBeginner
1Question 1 of 1
javascriptWhat is the difference between Firebase Realtime Database and Cloud Firestore?
Explanation & Concept
• Realtime Database: Firebase's original database. Stores data as one giant monolithic JSON tree. Offers lower latency for simple state syncing, but has limited querying capabilities (queries can only sort/filter on a single property) and does not scale past ~200,000 concurrent connections without manual sharding. • Cloud Firestore: The modern successor. Stores data as discrete documents in collections. Offers shallow querying, robust multi-attribute compound filtering, automatic multi-region scaling, and richer security rules.
Code Example
javascript
// Firestore allows querying sub-documents without fetching child data:
// Fetching a user document does NOT automatically download its 10,000 subcollection posts!
const userRef = doc(db, "users", "user_123");
const userSnap = await getDoc(userRef); // Lightweight, fast read!How It Works & Key Takeaways
Firestore's shallow queries mean document reads only fetch the specified document, keeping bandwidth and query costs low.
Mock Test · 1 Questions · Optional
Ready for Security Rules?
Take a quick test to evaluate yourself, or move straight to the next module.
Beginner1 questions