Thuta Learning
IntermediateDevOps & ToolsIntermediate

Data Structure

Firebase TutorialLesson 12

Data Structure

If you think through your Firestore structure carefully from the start, your queries, rules, and performance will all be much better down the line.

Simple Notes App Structure

javascript
users/{userId}
  name: 'Sai'
  email: 'sai@example.com'

notes/{noteId}
  ownerId: '{userId}'
  title: 'Firebase လေ့လာရန်'
  content: 'Auth, Firestore, Storage စမ်းမယ်'
  createdAt: serverTimestamp()
  isPinned: false

Why add ownerId?

ownerId tells you which user owns a given note. In queries, you can use where('ownerId', '==', user.uid) to read only your own notes, and in Security Rules you can check ownership the same way.

Best practice

You can shorten document field names, but being clear matters more than being short. ttl instead of title, ct instead of createdAt — the longer, clearer names make life easier for whoever reads the code later.

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.