# Services : Firebase : DB vs Firestore
| | Database | Firestore |
| :--------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| Structure | single JSON tree | collections of documents with subcollections, up to 100 levels |
| Offline Support | Android \| Apple | all platforms |
| Presence Support | Yes | - |
| Querying | - sort -or- filter<br>- no indexes, performance degrades<br>- deep — returns subtree<br>- access at any granularity, down to individual leaf-node | - compound sorting & filtering<br>- indexes<br>- shallow — returns documents w/o subcollections<br>- must always return whole documents |
| Writes | - set and update ops | - set and update ops<br>- advanced transformations (i.e., array and numeric ops) |
| Transactions | - tx are atomic on a specific subtree | - tx can atomically read/write data from any part of the db<br>- multi-document transactions |
| Scalability | - scaling requires sharding<br>- 200k connections & 1k writes/s per DB<br>- no write limits | - scales completely automatically<br>- 1M connections & 10k write/s (and growing)<br>- write limits to individual documents or indexes |
| Security | - cascading rules language that separates authorization and validation | - non-cascading rules that combine authorization and validation<br>- rules can constrain queries:<br> - if a query's results might contain data the user doesn't have access to, the entire query fails |
| Pricing | - charges for bandwidth/storage at high rate | - mostly charges on db ops + bandwidth/storage at a low rate |