<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/denormalizing-your-data-is-normal-6lgkaw7pw" -->

---
title: Denormalizing Your Data is Normal | daily.dev
description: Explains why relational-style SQL queries don't map cleanly onto Firebase's tree-based real-time database, which supports only querying by path and by...
canonical: https://daily.dev/posts/denormalizing-your-data-is-normal-6lgkaw7pw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Denormalizing Your Data is Normal | daily.dev
og:description: Explains why relational-style SQL queries don't map cleanly onto Firebase's tree-based real-time database, which supports only querying by path and by...
og:url: https://daily.dev/posts/denormalizing-your-data-is-normal-6lgkaw7pw
og:image: https://api.daily.dev/og/posts/6LGkaw7pw.png
og:image:alt: Denormalizing Your Data is Normal
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Denormalizing Your Data is Normal

**[Firebase](https://daily.dev/sources/firebase-blog)** · 8 min read · 0 upvotes · 0 comments

## Summary

Explains why relational-style SQL queries don't map cleanly onto Firebase's tree-based real-time database, which supports only querying by path and by priority. Walks through designing a Hacker News/Reddit-style app first with a SQL schema, then reworks it for Firebase by denormalizing data — duplicating comment references under both links and users — so lookups stay fast without a WHERE clause. Covers handling writes, edits, and deletions across duplicated data locations, and notes a 2015 update pointing to newer Firebase query features and structuring-data documentation.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://firebase.blog/posts/2013/04/denormalizing-your-data-is-normal>

## Questions this post answers

### Why can't I use a WHERE-style query to get all comments for a link in Firebase's real-time database?

Firebase's real-time database only supports querying by path (location) and by priority, with no equivalent of SQL's WHERE clause. To retrieve all comments for a link, you must denormalize by explicitly storing a list of comment IDs under each link node, then fetch each comment individually using its ID.

_Developers wrestling with NoSQL data modeling trade-offs can find more real-world patterns on daily.dev._

### How do you denormalize data in a NoSQL tree database like Firebase to support querying comments by both link and author?

Store the same comment reference in multiple locations: under the link's node (comments: {commentId: true}) and under the user's node (comments: {commentId: true}), while keeping the actual comment content in a single top-level comments collection. This duplicates references at write-time so reads for either link-based or author-based comment lists stay fast, trading disk space for reduced query complexity.

_Anyone comparing NoSQL data modeling strategies can track patterns like this via daily.dev._

## Similar posts on daily.dev

- [Firestore Data Modeling Guide: Embedded Documents vs Referencing \(with a Blog Case Study\)](https://daily.dev/posts/firestore-data-modeling-guide-embedded-documents-vs-referencing-with-a-blog-case-study--xstrcq8u3) · freeCodeCamp · 1 upvotes · 0 comments
- [Choosing Between Normalization Or Denormalization](https://daily.dev/posts/choosing-between-normalization-or-denormalization-y3lqy5l9x) · System Design Codex · 9 upvotes · 0 comments
- [Normalization, Denormalization, and Joins](https://daily.dev/posts/normalization-denormalization-and-joins-kfpparenc) · Towards Dev · 0 upvotes · 0 comments
- [How Firestore Structures Data and How to Perform CRUD Operations With It](https://daily.dev/posts/how-firestore-structures-data-and-how-to-perform-crud-operations-with-it-odioykply) · freeCodeCamp · 1 upvotes · 0 comments
- [Imperative to relational](https://daily.dev/posts/imperative-to-relational-yklrn3mcs) · Lobsters · 0 upvotes · 0 comments

---

Tags: [#database](https://daily.dev/tags/database), [#firebase](https://daily.dev/tags/firebase), [#nosql](https://daily.dev/tags/nosql)

[View this post on daily.dev](https://daily.dev/posts/denormalizing-your-data-is-normal-6lgkaw7pw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Denormalizing Your Data is Normal","url":"https://daily.dev/posts/denormalizing-your-data-is-normal-6lgkaw7pw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/denormalizing-your-data-is-normal-6lgkaw7pw"},"datePublished":"2026-08-23T12:20:29.090Z","dateModified":"2026-08-23T12:29:37.371Z","description":"Explains why relational-style SQL queries don't map cleanly onto Firebase's tree-based real-time database, which supports only querying by path and by...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Firebase","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Firebase","logo":"https://media.daily.dev/image/upload/s--i395oqZH--/f_auto,q_auto/v1787487448/logos/firebase-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/firebase-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/denormalizing-your-data-is-normal-6lgkaw7pw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"database,firebase,nosql","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Firebase","item":"https://daily.dev/sources/firebase-blog"},{"@type":"ListItem","position":3,"name":"Denormalizing Your Data is Normal"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/denormalizing-your-data-is-normal-6lgkaw7pw#faq","mainEntity":[{"@type":"Question","name":"Why can't I use a WHERE-style query to get all comments for a link in Firebase's real-time database?","acceptedAnswer":{"@type":"Answer","text":"Firebase's real-time database only supports querying by path (location) and by priority, with no equivalent of SQL's WHERE clause. To retrieve all comments for a link, you must denormalize by explicitly storing a list of comment IDs under each link node, then fetch each comment individually using its ID. Developers wrestling with NoSQL data modeling trade-offs can find more real-world patterns on daily.dev."}},{"@type":"Question","name":"How do you denormalize data in a NoSQL tree database like Firebase to support querying comments by both link and author?","acceptedAnswer":{"@type":"Answer","text":"Store the same comment reference in multiple locations: under the link's node (comments: {commentId: true}) and under the user's node (comments: {commentId: true}), while keeping the actual comment content in a single top-level comments collection. This duplicates references at write-time so reads for either link-based or author-based comment lists stay fast, trading disk space for reduced query complexity. Anyone comparing NoSQL data modeling strategies can track patterns like this via daily.dev."}}]}
```

