Model Relational Data in Firestore NoSQL
Vložit
- čas přidán 7. 09. 2024
- Learn how to model and structure data relationships with the Firestore NoSQL Database. We build simple one-to-many and many-to-many relationships by modeling a twitter-inspired app. angularfirebas...
- Firestore Structuring: firebase.googl...
- NoSQL Document DB - en.wikipedia.o...
Oops, meant to say "no greater than 1MB" at 1:10 - I hope this gives you some ideas for basic relational modeling in Firestore, but there are more advanced techniques that I will cover in the future.
I’d love to see more techniques about data modelling. Keep up the good work :)
😂 "documents need to be at least 1MB or smaller" left me scratching my head
Anyway, thanks for the content.
your technique of demonstrating possibilities is simply awesome, straight to the point, without diversions. well-rehearsed.. awesome ! :)
how to check the size of the document ?
@@peet91pop I m not got the general content of this video, can I conclude it become 1 sentence "To create relationship in NoSQL, we can use both Normalize and Denormalize method?" Normalize is separate them to Collections, And Denormalize is use "Object Field"
This is perhaps the only channel where I watch in 1x and pause often.
That's funny because this video is the first video I watched in 1.75x
I was thinking the exact same thing lol
I usually watch on X1.5 , or even faster in case I'm familiar with the subject
But here on fireship no no no 😂 X1 speed and I need100% of my brain
Exactly . So dense with valuable information
@@gamesland2067 hey
For anyone watching this in Feb 2019 and following along, there is no more "object" field for the documents. It's now called "map".
you saint
Arigatou senpai
The hero we need, not the hero we deserve.
nice to know. Just started working with it :D
cheers!
I am a Spanish speaker and I appreciate your speech clarity and the knowledge of this channel. Thank you so much.
6 years old and it still helped me plan out the structure for my project. Thank you!
OMG, seeing this for the first time in my life to try to do something using flutterflow and firestore. Glad to finally see some noSQL stuff (I'm VERY SQL oriented for over 20 years using relational databases).
Hands-down best video series on Angular and Firebase! Keep up the Firestore videos! We'll definitely need it since it's still in beta.
I agree, one of better videos that explains how to apply relational techniques to Firebase. This is what SQL developers are looking for to come over to Firebase.
Exactly, that have prevented me from entering into firebase in the past till recently I gave it a try and this video summarizes all what I have read along the way and what I have implemented.
Jeff, you make learning more fun for me. Thanks
5:20 It is now possible to make queries across collections and subcollections with the same name using collection group queries.
Actually taught me NoSQL and Firestore at the same time. Amazing videos as usual.
Exactly the information I needed.
The user -> tweets model is applicable to so many other applications.. like stores -> products.
Which is how this helped me resolve my data structure.
Thanks!
of all modeling videos, this one is the best. Thank you so so much!
Still useful today. Wow your videos have come far, and so has your voice!
I just started working with databases and found firebase and your videos make understanding it so much easier and quicker. Great work!
The best explaination on Data modeling in Firestore👏👏
3:34, you can now actually do this! Firebase is really growing and allows you to defined those queries.
That's a great introduction to the NoSQL mindset thanks you
Hands down the best CZcams channel for coding
NoSQL feels so primitive compared to relational dbs. I quite like its simplicity but do feel uneasy by the lack of relations
I just watch your half of your videos because of the voice combined with the background jingle :P no joke, love them
It would be helpful to see examples of typical queries. How would we get the tweets a specific user has liked? All of the tweets liked by that user? The tweets of user A that were liked by user B? I think I understand the concepts here but it hasn't quite clicked in my mind. Probably I just need to try some of these exercises myself.
Always a very good content by the way. Thanks for sharing. I am a very satisfied Pro Member and highly recommend it to all.
+ Daniel I'm very glad to hear that, thanks for sharing your feedback :)
Great video Jeff, thank you! This was an excellent topic to cover. It confirmed what I already learned from talking to you in Slack, and gave me some extra insight.
Your content is super awesome! Maybe you could one day do a video on how to get data from firestore to datastudio, I bet it would be incredibly useful not only for me. Keep it like that.
Wow I just implemented this approach using exactly the same method for a similar situation. I had problem with Firebase9 since I couldnt nest the likes inside a document inside a post So I decided to do take the easier approach and I was hoping the I didnt ruin my project.
But after I watched your suggested video I feel 100x more confident about it. Thanks alot ❤️❤️
great Video .. Thanks from Germany Leonardo
this guy is on speed
Exactly, I was commenting on this. He is too fast. Although tutorial is good.
The speed is great!
@@StephenRayner ok
@@ajaykotiyal427 just slow it down in the CZcams player!
Its called adhd
Awesome videos man, simple and straight to the point! Keep it up
Great explanation mate. Just what I needed.
Not an Angular guy but i use Firestore often this is truly amazing thanks alot
Thank you! What do you use Firestore with?
Angular Firebase Android development in native Java, actually modeling my current database using some of the principles you've mentioned
At 6:12 it is stated that we can return tweets by multiple users and then at 6:20 it is stated that we can also scope a query to a specific user. My question is... is it possible to scope the query to multiple users (a friend list), lets say an array or user ID's?
I am also curious
Exactly what i needed, thank you. Realized that I should just go with a SQL db
Nice and helpful tutorial and hard to find one like this addressing data modeling specifically for firebase! But I have to watch at 0.5 speed to fully understand the content lol!
Damn... this channel is A+ class.
finally i understand now how the noSQL work. thank for your awesome video.
G’day, a noob query: @7:00 - There was a mention to check if an user has hearted a post by checking whether the document exists for userid_tweetid. Doing this operation at scale, wouldn’t it easily consume lot of GET requests?Would it be a better alternative to write the hearted tweet id per user basis to Firestore and sync the same in realtime back to the client so that the client always have the list of tweets thus making the check locally than to reach the server?
CZcams recommends me this video while I am working on a Firestore implementation in Android. I wonder if they can view my PC.
Yes, yes they can
@Wafi Hartono Yes, it's me
I am so surprised that this is the same way that i was thinkink to use firestore database😁
thanks, answered really well the question, how we solve complex situations in noSql .... by yourself !
I remember we use this technique with Firebase Realtime Database before Firestore and i can't see any news except modification on query code, any way thank you a lot for your tutorials.
The query methods are a big improvement + it gives you the flexibility for shallow queries when nesting. Thanks for the feedback :)
Bro you deserve a subscribe!
So, if I am creating a quiz app, and I in the end want to query what the average score of ALL users are, I basically have to have my questions as a root document, and add users ID's to each questions answer as an array? I.e. Question 1 > Option A > User 1, User 2, User 3. Then Question 1 > Option B > User 4, User 10, User 101. Then Question 2 > Option C > User 1, User 3, User 101.
Or am I missing the point here?
Really struggling with how to design a database where I can store users answers to the questions, but not only that, storing which question each user bookmarked for later review, and also make it possible for users to see statistics per chapter, counts of bookmarks per chapter/total questions, correct answers per chapter/total questions etc.
Jeff, you are awesome!!!
+Mateja Thank you :)
Is you??😳
5 yrs back ur voice 🤐🔥❤️
No one can beat you sir
how would you get all tweets along with up to date user data such as user name and age not just user id ... like joins in sql
But wouldn't it be extremely expensive to manage your data this way? If Firebase charges for every read and you want to get all tweets every time, and you have thousands of users and potentially millions of tweets
At that point you should be able to afford it.
That's true. That's why I often try to end up by not having smallest possible documents with relational data, but with redundancy for data, that is often read, but not often written (e.g. a tweet in this case). I thought costs might be also a topic of this video. Sadly it's not mentioned.
@@michaelraring9473 Danke bro!!
If you’re still looking for an answer to this, look up Google I/O 19 firebase data modeling on CZcams. It counts as a single read so stay cheap
at 7:10 .. Does that mean we will need to make a document id for each user with a specific tweet? that a huge data
Hey Jeff, great video. Why don't you use the 'reference' data type? for a user document rather than creating a new field?
episode 63? is this part of some series? if so where can I find the full series or playlist?
Check his channel. He offers a bunch of free videos on youtube. He also has some paid ones on his site at fireship.io I believe. There's also a stripe community you can join. His videos are by far the most useful I've found.
whaou!!! wath a nice topic on a nice video, thanks
Eu estava com duvidas quanto a construção dos relacionamentos, foi de grande ajuda esse video.
(I was in doubt as to the construction of the relationships, this video was very helpful.)
- Follower of Brazil
awesome as always
Doesn't it look like what you're doing to solve any problem that arise from nesting collection (namely the impossibility to query all documents subcollection at once) removing the nesting by bringing the subcollection to the root to then use it exactly like any other relational SQL database ?
it just seems like SQL with extra steps and hurdles.
Thanks for the video. It would been better to first represent the relations as relational database and then showing how to do this in nosql way.I was watching you type but many times you were explaining some other concept like many-to-many. Difficult to follow thru.
Basically, donot use nested collections. Instead, use collections as tables and documents as rows 😉👍
Yeah that was also my key take away. Also it seems if you pull in a document, the sub collection will not be included anyway so you might still need to make an extra call, which could might as well have been to a real collection.
Very good job explaining this. but one thing for sure it doesn't need to be in 9 mins
Early in the video OP showed creating a document with userId and instructorId properties and claimed this was many-to-many. That's not mtm it's just two foreign key references from the same document to two documents in presumably the same collection. Maybe what OP meant to do was make the userId property and array of userId? Does firebase support multiple indexable values for a single field like elasticsearch?
6:52 How do you get the user info from 'tweets' collection if there's no join? example output will be: USER ONE - 'User tweet this one.' , USER TWO - 'This is other tweet from this user'
Hi Jeff, wondering if it is better using userId as the "Document ID" for "tweets" and any other collection related to the user. This way you can use:
/user/{userId} to show user information
/tweets/{userId} to list every users' tweets
/following/{userId} to list every followed user
/followed/{userId} to list every user following the user
I don't think so. This *may* be more appropriate to be applied on a server endpoint than on firebase. I have little to no experience here but it feels better to use the /model/{modelId} most if not all the times so you can always retrieve unique documents.
I am working on a project where videos will be displayed and users will be able to comment on videos. How will be the relational database for it on firestore.
Did collection group queries made the part about the tweets obsolete?
easy to understand. good job!!
@Fireship why not putting hearts collections under each user ? With and object {tweetId1 : true, tweetId558: true}. I would kindly like to know if this can cause issue or not ? Because liked tweets are linked to the users, so creating a collections under users/${userId} make sense no ? Instead of having it outside create the need to link it. And has you said even if the collections is big it's not a problem (if the user like tons of tweets should not be an issue). Cloud functions triggered where like or unlike will work the same for total count.
thank u it helps me a lot
7:16 will using a composite id of the User and Tweet lead to issues involving hotspotting? "Avoid high read or write rates to lexicographically close documents" - Firestore best practices doc. I'm currently in the process of implementing some backend logic that uses this idea, but I'm concerned that this idea won't work in the long run.
awesome video bro, thank you very much
Does the size of my db change the response time? Or has Google abstracted it enough to not make a difference?
Hey, one question tho.
I understand why we normalized the structure so that we can query all the tweets in a single day if we want to. But what about if the user wants to see all of his tweets? Are we looking at some data duplication in this case?
new to firebase..... dose it increase read and write count...or increase billing
I always watch videos on this channel in 0.5-0.75x speed. He's going too fast for someone who's learning like me.
does this create lot of document read and the cost will be pricey
Do you know of any technique to reduce the number of document reads when querying a collection of posts? currently working on an app and it seems wasteful that just strolling through a paginated profile of a user can cause upwards of 100 reads when you have many posts.
I thought you'd demonstrate the use of 'reference' field type... any thoughts on that?
Keep up the great work! :)
My thoughts exactly.
const ref = db.collection('assign');
ref.where( 'email', '==', user.email )
How to compare assign.email and user.email in this case ? I want user.email to become a variable that changes from user to user that will display only the email that match.
Nice explanation
Hi Jeff, for the trick mentioned in 7:20 - Does a firestore call to check if the user has liked a post need to be made for every tweet he views? Will this not exponentially increase the read costs?
Guys, check out JaguarDB, which is awesome. Time series data, geolocation data all
in one natively. Automatic time window rollup.
I'm building an app with Angular and Firebase but would like to learn as much about Firebase (noSql) data modeling first. Any resources you can point me to. Thanks!
For those watching in 2020, you can now do cross-collection queries
Thank you so much bro I was lost
Wow loved it
So how would you get a list of tweets a user hearted?
Query through the 'hearts' document where userID == desiredUser
Can someone link me the video that is episode 63 that is referenced please :)
Great explaination
Man i love how easy firebase is to setup but ABSOLUTELYYY hate its querying and how documents are stored. It's seriously the worst I've seen in 10 years of programming. You can tell Google devs NEVER code things for the web. Google is SOO bad at making web based libraries. It's SOO hard to just get a document and update it.. which is just ridiculous.
I'm sorry because my English is not good, I can't understand this video. I'm easier to understand the language of the text
then let me ask
which is better for firestore between having many children vertically or having multiple collections horizontally and using keys. ?
I beg you to explain with text in the comments.
Doesn't it require us to write data on multiple documents for updating a single field? Write is much more expensive than read.
Hi, I'm new to coding. Are these videos good for people trying to build a firebase database in Swift?
Does it work the same way in Datastore in google cloud?
Hi, this was a nice intro video for me. Do you plan to make longer video tutorials on this Firebase topic?
Great tutorial! Can you please post a tutorial for 2 cascade dropdown list with array object thank you very much
Amazing!!
Please tell the name of into music or if it is your own music, give me payment link, I'll buy...
Hey,
What about lookup tables?
How will you model those with firestore ?
How do you model the data if you want to show only the tweets tweeted by users you follow?
Awesome video +++++++++++++ 😃
Please open the subtitles for each video.Thanks
Can firebase auto generate object id (let say userID) for me, or i have to type it down manually. I know that firebase can create the key ID but how can i get that ID and put it in other object?
If it doesn't, you have access to free libraries in all popular programming languages to generate UUIDs. Your client, whether that's a web browser or server, can create the UUID and include it as the new document's ID as it creates the document in Firestore.
Example: www.npmjs.com/package/uuid