Converting SQL structures to Firebase structures - The Firebase Database For SQL Developers #2
Why Stack Overflow recommends it
Stack Overflow users link it when answering or asking about Firebase data modelling, especially how to handle relationships and denormalization when coming from SQL.
Recommended by 3 people across 4 different months, 2017 to 2020.
What it is
A short episode from the official Firebase channel's series for SQL developers. It shows how to take a relational data model and restructure it for the Firebase Realtime Database, using flat, denormalized data and key lookups such as a many-to-many users, events and attendees example.
What people said
Strong rec naton · 2017-01 · Stack Overflow · on “Vue.js: How to map a list of keys to Firebase objects?”
I think you have to denormalize/duplicate some data there. I had a similar situation and this Firebase video cleared a lot of things up for me: [this video] (Link updated to passage at 2:22. The whole serie is worth watching btw.) My shot at it would be adding (Firebase) keys in "listitems", just like you have done in "items", with only the most crucial data there, so that you can link to a full description
Recommends Ewald Benes · 2017-09 · Stack Overflow · on “Android - Firebase - Getting Child of Child Data”
@TheStudent123 you're welcome! Nevertheless I recommend to take a look at this video [this video] about how to structure your data. I think your data model might not be the best fit for what you're trying to accomplish.
Recommends Ewald Benes · 2017-10 · Stack Overflow · on “firebase structure college db”
Looking at your design, I think, you are on the right track. I'll give some possible hints of what you can take care of. When designing the structure of a Firebase database design rules of non-relational databases should be kept in mind. One of them is denormalization. Keep the hierarchy flat! That's an important performance factor for data change listeners since all subnodes are involved. That's what you've done so far. Relationship of entities can be achied by using the keys. Exactly as you did it in the Courses_Department node. The built-in creation of keys should be used. They should be universally unique. Here's [this video] a good explanation when coming from relational databases.
Recommends TheBen · 2017-11 · Stack Overflow · on “Firebase database structure suggestion”
First some considerations on the structure of your database read this [LINK] and also you may find this [this video] youtube series useful if you know SQL database. here I share a few points though. 1.Try to keep your database as shallow as possible, i.e, avoid deep nesting of your data. 2.structure your data such that a user is downloading only what they need. Now keep in mind, firebase charges per read/write so there is a fine line here to optimize your costs vs what user is paying for data. But that shouldn't really be a concern as long as your app is not dumping huge amount of data. For calculating your average score, you need to write a Firebase function ( samples [LINK] ) that is triggered
Cites Martin7_O · 2019-06 · Stack Overflow · on “Get user's events with Firebase (many to many relationship)”
I'm a Front-End Developer and for the first-time, I'm using Firebase to build an application. I read some documentation/articles and watched this interesting video about foreign keys (many to many relationship): [this video] . I'm trying to apply this approach to retrieve events for a specific user. Ideally, I want to get this information without requesting/paying for too much data. First, this is how I set-up the following database structure (see video): { users: "abc": { firstname: "Maxime", ... }, "def": { firstname: "John", ... }, }, events: { "eventAbc-": { title: "Some great event", ... }, "eventDef": { title: "Another great event", ... } }, eventAttendees: { "eventAbc": { abc: true, def: t
Cites Lakshay Dulani · 2020-02 · Stack Overflow · on “How to model data in NoSQL Firebase datastore?”
I want to store following data: Users, Events, Attendees (similar to Firebase's example given here: [this video] ) My Firebase store is like the following: Users - Collection { "9582940055" : { "name" : "test" } } Every user is a different document. Am I doing it correctly? If yes, I have kept Mobile number of every user as Document Id instead of auto id , as the mobile number is going to be unique and it will help me in querying. Is this right? Events - Collection { "MkyzuARd8Uelh0qD1WMa" : // auto id for every event { "name" : "test", "attendees" : { "user": 'Lakshay' } } } Here, I have kept attendees as a Map inside the Event document. Is it right or should I make Attendees as a collection ins
Cites CTOverton · 2020-04 · Stack Overflow · on “What's the best way to work with a relational firestore model?”
I followed this video on the best practices for creating flat databases with firestore: Converting SQL structures to Firebase structures [this video] I came up with something that looks like this: const firestore = { events: { eventID: { // Doc description: "Event Description", // Field title: "Event Title", // Field } }, eventComments: { // Collection eventID: { // Doc comments: { // Field commentID1: true, // Value commentID2: true, // Value commentID3: true, // Value } } }, comments: { // Collection commentID1: { // Doc createdAt: "Timestamp", // Field createdBy: "uid", // Field content: "Comment Body" // Field }, commentID2: {...}, commentID3: {...}, }, }; I'm not sure what the best way to ge