Model Relational Data in Firestore NoSQL

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 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...

ความคิดเห็น • 214

  • @Fireship
    @Fireship  6 ปีที่แล้ว +89

    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.

    • @wilfrodebodo
      @wilfrodebodo 6 ปีที่แล้ว +4

      I’d love to see more techniques about data modelling. Keep up the good work :)

    • @y9tw0t
      @y9tw0t 6 ปีที่แล้ว +3

      😂 "documents need to be at least 1MB or smaller" left me scratching my head
      Anyway, thanks for the content.

    • @HassanMalikTW
      @HassanMalikTW 6 ปีที่แล้ว +1

      your technique of demonstrating possibilities is simply awesome, straight to the point, without diversions. well-rehearsed.. awesome ! :)

    • @peet91pop
      @peet91pop 6 ปีที่แล้ว

      how to check the size of the document ?

    • @binhcoolfreestyles
      @binhcoolfreestyles 5 ปีที่แล้ว

      ​@@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"

  • @tarmac5482
    @tarmac5482 3 ปีที่แล้ว +89

    This is perhaps the only channel where I watch in 1x and pause often.

    • @gamesland2067
      @gamesland2067 3 ปีที่แล้ว +1

      That's funny because this video is the first video I watched in 1.75x

    • @sharbelokzan9673
      @sharbelokzan9673 3 ปีที่แล้ว +3

      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

    • @Beny123
      @Beny123 2 ปีที่แล้ว

      Exactly . So dense with valuable information

    • @TheSUMMIE
      @TheSUMMIE 2 ปีที่แล้ว

      @@gamesland2067 hey

  • @user72974
    @user72974 5 ปีที่แล้ว +297

    For anyone watching this in Feb 2019 and following along, there is no more "object" field for the documents. It's now called "map".

  • @simonfeliperuavargas5134
    @simonfeliperuavargas5134 4 ปีที่แล้ว +5

    I am a Spanish speaker and I appreciate your speech clarity and the knowledge of this channel. Thank you so much.

  • @mohamethseck
    @mohamethseck 5 หลายเดือนก่อน

    6 years old and it still helped me plan out the structure for my project. Thank you!

  • @innerthreatcircus5651
    @innerthreatcircus5651 8 หลายเดือนก่อน +1

    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).

  • @bienvenidovillabroza351
    @bienvenidovillabroza351 3 ปีที่แล้ว +9

    Actually taught me NoSQL and Firestore at the same time. Amazing videos as usual.

  • @sebbel3260
    @sebbel3260 ปีที่แล้ว +1

    Still useful today. Wow your videos have come far, and so has your voice!

  • @psaunder1975
    @psaunder1975 6 ปีที่แล้ว +23

    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.

    • @cesarmurillo6192
      @cesarmurillo6192 3 ปีที่แล้ว

      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.

  • @domknguyen
    @domknguyen 6 ปีที่แล้ว +11

    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.

  • @razakadam74
    @razakadam74 6 ปีที่แล้ว +16

    Jeff, you make learning more fun for me. Thanks

  • @h.vats_
    @h.vats_ 3 ปีที่แล้ว +12

    5:20 It is now possible to make queries across collections and subcollections with the same name using collection group queries.

  • @algoconqueror3579
    @algoconqueror3579 ปีที่แล้ว

    The best explaination on Data modeling in Firestore👏👏

  • @antoinederoose499
    @antoinederoose499 3 ปีที่แล้ว +1

    That's a great introduction to the NoSQL mindset thanks you

  • @monome3038
    @monome3038 6 ปีที่แล้ว +5

    of all modeling videos, this one is the best. Thank you so so much!

  • @davidakposibruke5444
    @davidakposibruke5444 4 ปีที่แล้ว +1

    I just started working with databases and found firebase and your videos make understanding it so much easier and quicker. Great work!

  • @greggord-hume3979
    @greggord-hume3979 2 ปีที่แล้ว

    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!

  • @martinschulze5399
    @martinschulze5399 3 ปีที่แล้ว

    I just watch your half of your videos because of the voice combined with the background jingle :P no joke, love them

  • @hiringcafe
    @hiringcafe 4 ปีที่แล้ว

    Hands down the best TH-cam channel for coding

  • @joshuapetitma6077
    @joshuapetitma6077 3 ปีที่แล้ว +2

    3:34, you can now actually do this! Firebase is really growing and allows you to defined those queries.

  • @Leonardo_A1
    @Leonardo_A1 10 หลายเดือนก่อน

    great Video .. Thanks from Germany Leonardo

  • @Trinks
    @Trinks 6 หลายเดือนก่อน

    Great explanation mate. Just what I needed.

  • @JanacMeena
    @JanacMeena 2 ปีที่แล้ว

    Exactly what i needed, thank you. Realized that I should just go with a SQL db

  • @caiomar
    @caiomar 5 ปีที่แล้ว +23

    this guy is on speed

    • @ajaykotiyal427
      @ajaykotiyal427 4 ปีที่แล้ว +1

      Exactly, I was commenting on this. He is too fast. Although tutorial is good.

    • @StephenRayner
      @StephenRayner 4 ปีที่แล้ว +1

      The speed is great!

    • @caiomar
      @caiomar 4 ปีที่แล้ว

      @@StephenRayner ok

    • @mountainslopes
      @mountainslopes 3 ปีที่แล้ว

      @@ajaykotiyal427 just slow it down in the TH-cam player!

    • @jesseb0rn51
      @jesseb0rn51 3 ปีที่แล้ว

      Its called adhd

  • @michaelffasd23
    @michaelffasd23 6 ปีที่แล้ว +1

    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.

  • @ArturoCamposConde
    @ArturoCamposConde 5 ปีที่แล้ว +5

    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.

  • @mike73783
    @mike73783 5 ปีที่แล้ว +5

    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.

  • @nxone9903
    @nxone9903 2 ปีที่แล้ว +2

    NoSQL feels so primitive compared to relational dbs. I quite like its simplicity but do feel uneasy by the lack of relations

  • @tomasznowak2032
    @tomasznowak2032 3 ปีที่แล้ว

    Damn... this channel is A+ class.

  • @alexwilliams677
    @alexwilliams677 6 ปีที่แล้ว +2

    Awesome videos man, simple and straight to the point! Keep it up

  • @danielborges.
    @danielborges. 6 ปีที่แล้ว +3

    Always a very good content by the way. Thanks for sharing. I am a very satisfied Pro Member and highly recommend it to all.

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      + Daniel I'm very glad to hear that, thanks for sharing your feedback :)

  • @anazi
    @anazi ปีที่แล้ว

    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 ❤️❤️

  • @budiedev5820
    @budiedev5820 6 ปีที่แล้ว

    finally i understand now how the noSQL work. thank for your awesome video.

  • @ChilaKasonde
    @ChilaKasonde 6 ปีที่แล้ว

    Not an Angular guy but i use Firestore often this is truly amazing thanks alot

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      Thank you! What do you use Firestore with?

    • @ChilaKasonde
      @ChilaKasonde 6 ปีที่แล้ว +1

      Angular Firebase Android development in native Java, actually modeling my current database using some of the principles you've mentioned

  • @hangchen6131
    @hangchen6131 6 ปีที่แล้ว

    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!

  • @kethdominictacatani5837
    @kethdominictacatani5837 8 หลายเดือนก่อน

    Bro you deserve a subscribe!

  • @farishmd2241
    @farishmd2241 2 ปีที่แล้ว

    I am so surprised that this is the same way that i was thinkink to use firestore database😁

  • @tristanheilman3967
    @tristanheilman3967 4 ปีที่แล้ว +4

    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?

  • @javadziaebrahimi3568
    @javadziaebrahimi3568 5 ปีที่แล้ว +1

    awesome as always

  • @mateja176
    @mateja176 6 ปีที่แล้ว +6

    Jeff, you are awesome!!!

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      +Mateja Thank you :)

  • @CarlosAlbertoBrasil
    @CarlosAlbertoBrasil 4 ปีที่แล้ว

    thanks, answered really well the question, how we solve complex situations in noSql .... by yourself !

  • @inescherif5385
    @inescherif5385 ปีที่แล้ว

    thank u it helps me a lot

  • @codingkidda5173
    @codingkidda5173 6 ปีที่แล้ว

    No one can beat you sir

  • @drisscriss6479
    @drisscriss6479 ปีที่แล้ว

    Is you??😳
    5 yrs back ur voice 🤐🔥❤️

  • @codinginflow
    @codinginflow 6 ปีที่แล้ว +3

    TH-cam recommends me this video while I am working on a Firestore implementation in Android. I wonder if they can view my PC.

    • @TheEnde124
      @TheEnde124 4 ปีที่แล้ว

      Yes, yes they can

    • @codinginflow
      @codinginflow 4 ปีที่แล้ว

      @Wafi Hartono Yes, it's me

  • @kamalkamals
    @kamalkamals 6 ปีที่แล้ว

    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.

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      The query methods are a big improvement + it gives you the flexibility for shallow queries when nesting. Thanks for the feedback :)

  • @cheldap-softcheldap-soft900
    @cheldap-softcheldap-soft900 6 ปีที่แล้ว +2

    whaou!!! wath a nice topic on a nice video, thanks

  • @Neerajkumar-xl9kx
    @Neerajkumar-xl9kx 2 ปีที่แล้ว

    Wow loved it

  • @kyumamorita
    @kyumamorita 5 ปีที่แล้ว

    easy to understand. good job!!

  • @eduardorabanal2803
    @eduardorabanal2803 5 ปีที่แล้ว

    awesome video bro, thank you very much

  • @raghav4296
    @raghav4296 5 ปีที่แล้ว +2

    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?

  • @JoeTechster
    @JoeTechster 6 หลายเดือนก่อน

    Amazing!!

  • @RafaelSantos-pq4od
    @RafaelSantos-pq4od 6 ปีที่แล้ว

    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

  • @shoekneeawl
    @shoekneeawl 6 ปีที่แล้ว +2

    Hey Jeff, great video. Why don't you use the 'reference' data type? for a user document rather than creating a new field?

  • @sreeharsha75
    @sreeharsha75 ปีที่แล้ว

    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.

  • @elvisfernandes4157
    @elvisfernandes4157 6 ปีที่แล้ว +6

    I thought you'd demonstrate the use of 'reference' field type... any thoughts on that?
    Keep up the great work! :)

    • @cucco1
      @cucco1 6 ปีที่แล้ว

      My thoughts exactly.

  • @kenjihikmatullah1060
    @kenjihikmatullah1060 4 ปีที่แล้ว

    Nice explanation

  • @blasttrash
    @blasttrash 4 ปีที่แล้ว +12

    episode 63? is this part of some series? if so where can I find the full series or playlist?

    • @jamesblock8384
      @jamesblock8384 4 ปีที่แล้ว +2

      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.

  • @zakariaarrim5493
    @zakariaarrim5493 3 ปีที่แล้ว

    Thank you so much bro I was lost

  • @mohamedyoussef8835
    @mohamedyoussef8835 2 ปีที่แล้ว

    Awesome video +++++++++++++ 😃

  • @codewithluca
    @codewithluca 5 ปีที่แล้ว

    Great explaination

  • @josemg14
    @josemg14 5 ปีที่แล้ว +6

    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

    • @mileslemon
      @mileslemon 5 ปีที่แล้ว

      At that point you should be able to afford it.

    • @michaelraring9473
      @michaelraring9473 5 ปีที่แล้ว +2

      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.

    • @PlayerHeader
      @PlayerHeader 5 ปีที่แล้ว

      @@michaelraring9473 Danke bro!!

    • @TheNizzah1
      @TheNizzah1 5 ปีที่แล้ว

      If you’re still looking for an answer to this, look up Google I/O 19 firebase data modeling on TH-cam. It counts as a single read so stay cheap

  • @ollerandres
    @ollerandres 6 ปีที่แล้ว +1

    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

    • @edmundo096
      @edmundo096 5 ปีที่แล้ว

      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.

  • @kadiryumlu
    @kadiryumlu 2 ปีที่แล้ว +1

    Basically, donot use nested collections. Instead, use collections as tables and documents as rows 😉👍

    • @Squad2ND
      @Squad2ND 7 หลายเดือนก่อน

      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.

  • @SachalChandio
    @SachalChandio 2 ปีที่แล้ว

    you are awesome

  • @Pharaoh-99
    @Pharaoh-99 5 ปีที่แล้ว +2

    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

  • @SunsetRacer
    @SunsetRacer 6 ปีที่แล้ว

    Very good job explaining this. but one thing for sure it doesn't need to be in 9 mins

  • @Luggruff
    @Luggruff ปีที่แล้ว

    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.

  • @ismailmohamed6108
    @ismailmohamed6108 5 ปีที่แล้ว +1

    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

  • @eduardodelagarza3318
    @eduardodelagarza3318 5 ปีที่แล้ว +1

    Did collection group queries made the part about the tweets obsolete?

  • @Donaldo
    @Donaldo 5 ปีที่แล้ว

    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?

  • @qazyhn94
    @qazyhn94 5 ปีที่แล้ว

    great video

  • @Manish-fm5iv
    @Manish-fm5iv 6 ปีที่แล้ว +3

    So how would you get a list of tweets a user hearted?

    • @SquishySwishy
      @SquishySwishy 4 ปีที่แล้ว

      Query through the 'hearts' document where userID == desiredUser

  • @yndrywjynsyn
    @yndrywjynsyn 6 ปีที่แล้ว

    Hi, this was a nice intro video for me. Do you plan to make longer video tutorials on this Firebase topic?

  • @rachitkumarsingh3228
    @rachitkumarsingh3228 ปีที่แล้ว

    new to firebase..... dose it increase read and write count...or increase billing

  • @ray-lee
    @ray-lee 4 ปีที่แล้ว

    does this create lot of document read and the cost will be pricey

  • @Caelio
    @Caelio 2 ปีที่แล้ว

    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.

  • @muhammadafzal237
    @muhammadafzal237 2 ปีที่แล้ว

    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.

  • @moomoomamoo
    @moomoomamoo 5 ปีที่แล้ว

    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.

  • @tankki1583
    @tankki1583 4 ปีที่แล้ว

    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'

  • @avinashmphp
    @avinashmphp 6 ปีที่แล้ว

    Great tutorial! Can you please post a tutorial for 2 cascade dropdown list with array object thank you very much

  • @raphaelabadie2518
    @raphaelabadie2518 4 ปีที่แล้ว

    @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.

  • @user-wc1sm8cj8s
    @user-wc1sm8cj8s 3 ปีที่แล้ว +1

    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.

  • @hooligansofts7430
    @hooligansofts7430 5 ปีที่แล้ว

    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?

  • @whatthefunction9140
    @whatthefunction9140 3 ปีที่แล้ว

    Does the size of my db change the response time? Or has Google abstracted it enough to not make a difference?

  • @hoangkha410
    @hoangkha410 4 ปีที่แล้ว

    Please open the subtitles for each video.Thanks

  • @raghav4296
    @raghav4296 5 ปีที่แล้ว

    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?

  • @shiftEscape
    @shiftEscape 6 ปีที่แล้ว

    Great video! Keep it up! :)

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      +Alvin Will do, thank you!

  • @youwillyou7905
    @youwillyou7905 3 ปีที่แล้ว

    Guys, check out JaguarDB, which is awesome. Time series data, geolocation data all
    in one natively. Automatic time window rollup.

  • @Anto-xh5vn
    @Anto-xh5vn 2 ปีที่แล้ว

    What is the background music it's so cool

  • @mdjahidulislam9205
    @mdjahidulislam9205 3 ปีที่แล้ว

    How cloud function pricing works

  • @eminisrafil
    @eminisrafil 6 ปีที่แล้ว

    Thank you keep it up! Any hints on when geofiltering will be available? :)

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      I don't know, but I hope to see geo query support soon. You can expect a video as soon as it becomes available.

  • @vOnez212
    @vOnez212 6 ปีที่แล้ว

    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!

  • @gamingfirst0tv
    @gamingfirst0tv 5 ปีที่แล้ว

    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.

  • @soullesessess
    @soullesessess 4 ปีที่แล้ว

    Doesn't it require us to write data on multiple documents for updating a single field? Write is much more expensive than read.

  • @gjgiraldo1
    @gjgiraldo1 4 ปีที่แล้ว

    is better to use collectiongroup

  • @NikosKatsikanis
    @NikosKatsikanis 4 ปีที่แล้ว

    Does it work the same way in Datastore in google cloud?

  • @yndrywjynsyn
    @yndrywjynsyn 6 ปีที่แล้ว

    Hi, I'm new to coding. Are these videos good for people trying to build a firebase database in Swift?

  • @silvesterwali6565
    @silvesterwali6565 4 ปีที่แล้ว

    Do you have vue totural on firebase

  • @TheGrafox
    @TheGrafox 6 ปีที่แล้ว

    Thanks ... Most cases is shopping cart ... Can you make structure and queries for that in the future ... Thanks again

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      Yes, I have a shopping cart structure planned for a pro video in a few days on angularfirebase.com