Skip to content
Advertisement

What is the equivalent of a collection and a document of firebase in sql?

My question is that what is the equivalent of a collection and a document of firebase in other databases like SQL or MongoDB,

I know that there is a table in SQL but what is the equivalent of the following path:

/collection/document/collection

I mean that can I add a table(collection) to a document in SQL or mongoose and what is the architecture of that?

Thanks,

Advertisement

Answer

The closest equivalents to collections and documents in a relation database would be a table and a row. But as you’ve found, Firestore allows nesting collections under documents again, and there’s no way to nest tables under rows in relational databases.

What you’d do in a relational database is add a parent key to the rows that are under another record. So if you have a collection and a subcollection in Firestore, you could for example model that as two separate tables in a relational database, where you then give each row/record in subcollection a foreign key with the ID of the collection record that it falls under.

5 People found this is helpful
Advertisement