JOURNAL · CODE & DESIGN
Firebase Firestore Data Modeling Tips (NoSQL)
Correctly structuring data models when setting up Firestore directly determines the future speed and costs of the application.
Never think like a relational database
In NoSQL, data duplication is not an error, but a necessity. Embedding the username in every comment saves you from join operations.
// Storing author data in each comment document reduces read counts
{
id: "comment_1",
text: "Great project!",
author: {
uid: "123",
name: "Fahri",
avatar: "url..."
}
}
Stay tuned for more NoSQL tips!