I'm writing an education app and my current Firebase structure looks like:

   ∟ Lesson
       ∟ Modules (Includes video, audio, text and quiz modules in one collection)

Where "Course", "Lessons" and "Modules" are each collections. I also have a type field inside the module document that tells me what I should deserialize the document to (video object, audio object, etc. -- the objects only differ by a few fields).

Something tells me that I should instead separate the types of modules into their own collections however:

   ∟ Lesson
        ⊢ Video Modules
        ⊢ Audio Modules
        ⊢ Text Modules
        ∟ Quiz Modules

I've thought a lot about the two options and I can't seem to decide. Is there anything about not mixing the types inside collections specific to Firebase or noSQL databases that would help me decide?

  • Nobody can Tell you. We need to know more about how the modules relate to the lessons. Does order matter?
    – marstato
    Jan 10, 2020 at 18:10
  • Hi, no order does not matter although I do have an index field on the module documents that I use to order them in the UI. The lesson is a one to many relationship with modules. I think I've got an answer for myself (although it may not be the best one) so I'll post that below. Thank you
    – Nolence
    Jan 10, 2020 at 19:34

1 Answer 1


I ended up using one Module collection inside a Lesson that holds everything including videos, audio, text and quiz modules instead of multiple Collections inside a lesson.

This meant I didn't have to build a nest of streams for each collection, which looked unmanageable when I tried to implement it.

I now just have a Module interface that handles deserializing the document into the correct object (e.g. AudioModule) and in my UI, I use some if elses to check the type of the object to display the correct page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.