Model Relational Data in Firestore NoSQL

Sdílet
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...

Komentáře • 214

  • @Fireship
    @Fireship  Před 6 lety +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 Před 6 lety +4

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

    • @y9tw0t
      @y9tw0t Před 6 lety +3

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

    • @HassanMalikTW
      @HassanMalikTW Před 6 lety +1

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

    • @peet91pop
      @peet91pop Před 6 lety

      how to check the size of the document ?

    • @binhcoolfreestyles
      @binhcoolfreestyles Před 5 lety

      ​@@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 Před 3 lety +89

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

    • @gamesland2067
      @gamesland2067 Před 3 lety +1

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

    • @sharbelokzan9673
      @sharbelokzan9673 Před 3 lety +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 Před 2 lety

      Exactly . So dense with valuable information

    • @TheSUMMIE
      @TheSUMMIE Před 2 lety

      @@gamesland2067 hey

  • @user72974
    @user72974 Před 5 lety +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 Před 4 lety +5

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

  • @mohamethseck
    @mohamethseck Před 5 měsíci

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

  • @innerthreatcircus5651
    @innerthreatcircus5651 Před 8 měsíci +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).

  • @domknguyen
    @domknguyen Před 6 lety +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.

  • @psaunder1975
    @psaunder1975 Před 6 lety +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 Před 3 lety

      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.

  • @razakadam74
    @razakadam74 Před 6 lety +16

    Jeff, you make learning more fun for me. Thanks

  • @h.vats_
    @h.vats_ Před 3 lety +12

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

  • @bienvenidovillabroza351
    @bienvenidovillabroza351 Před 3 lety +9

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

  • @greggord-hume3979
    @greggord-hume3979 Před 2 lety

    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!

  • @monome3038
    @monome3038 Před 6 lety +5

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

  • @sebbel3260
    @sebbel3260 Před rokem +1

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

  • @davidakposibruke5444
    @davidakposibruke5444 Před 4 lety +1

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

  • @algoconqueror3579
    @algoconqueror3579 Před rokem

    The best explaination on Data modeling in Firestore👏👏

  • @joshuapetitma6077
    @joshuapetitma6077 Před 3 lety +2

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

  • @antoinederoose499
    @antoinederoose499 Před 3 lety +1

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

  • @hiringcafe
    @hiringcafe Před 4 lety

    Hands down the best CZcams channel for coding

  • @nxone9903
    @nxone9903 Před 2 lety +2

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

  • @martinschulze5399
    @martinschulze5399 Před 3 lety

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

  • @mike73783
    @mike73783 Před 5 lety +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.

  • @danielborges.
    @danielborges. Před 6 lety +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  Před 6 lety

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

  • @michaelffasd23
    @michaelffasd23 Před 6 lety +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 Před 5 lety +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.

  • @anazi
    @anazi Před rokem

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

  • @Leonardo_A1
    @Leonardo_A1 Před 10 měsíci

    great Video .. Thanks from Germany Leonardo

  • @caiomar
    @caiomar Před 5 lety +23

    this guy is on speed

    • @ajaykotiyal427
      @ajaykotiyal427 Před 4 lety +1

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

    • @StephenRayner
      @StephenRayner Před 4 lety +1

      The speed is great!

    • @caiomar
      @caiomar Před 4 lety

      @@StephenRayner ok

    • @mountainslopes
      @mountainslopes Před 3 lety

      @@ajaykotiyal427 just slow it down in the CZcams player!

    • @jesseb0rn51
      @jesseb0rn51 Před 3 lety

      Its called adhd

  • @alexwilliams677
    @alexwilliams677 Před 6 lety +2

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

  • @Trinks
    @Trinks Před 6 měsíci

    Great explanation mate. Just what I needed.

  • @ChilaKasonde
    @ChilaKasonde Před 6 lety

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

    • @Fireship
      @Fireship  Před 6 lety

      Thank you! What do you use Firestore with?

    • @ChilaKasonde
      @ChilaKasonde Před 6 lety +1

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

  • @tristanheilman3967
    @tristanheilman3967 Před 4 lety +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?

  • @JanacMeena
    @JanacMeena Před 2 lety

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

  • @hangchen6131
    @hangchen6131 Před 6 lety

    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!

  • @tomasznowak2032
    @tomasznowak2032 Před 3 lety

    Damn... this channel is A+ class.

  • @budiedev5820
    @budiedev5820 Před 6 lety

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

  • @raghav4296
    @raghav4296 Před 5 lety +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?

  • @codinginflow
    @codinginflow Před 6 lety +3

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

  • @farishmd2241
    @farishmd2241 Před 2 lety

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

  • @CarlosAlbertoBrasil
    @CarlosAlbertoBrasil Před 4 lety

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

  • @kamalkamals
    @kamalkamals Před 6 lety

    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  Před 6 lety

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

  • @kethdominictacatani5837
    @kethdominictacatani5837 Před 8 měsíci

    Bro you deserve a subscribe!

  • @Luggruff
    @Luggruff Před rokem

    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.

  • @mateja176
    @mateja176 Před 6 lety +6

    Jeff, you are awesome!!!

  • @drisscriss6479
    @drisscriss6479 Před rokem

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

  • @codingkidda5173
    @codingkidda5173 Před 6 lety

    No one can beat you sir

  • @Pharaoh-99
    @Pharaoh-99 Před 5 lety +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

  • @josemg14
    @josemg14 Před 5 lety +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 Před 5 lety

      At that point you should be able to afford it.

    • @michaelraring9473
      @michaelraring9473 Před 5 lety +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 Před 5 lety

      @@michaelraring9473 Danke bro!!

    • @TheNizzah1
      @TheNizzah1 Před 5 lety

      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

  • @ismailmohamed6108
    @ismailmohamed6108 Před 5 lety +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

  • @shoekneeawl
    @shoekneeawl Před 6 lety +2

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

  • @blasttrash
    @blasttrash Před 4 lety +12

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

    • @jamesblock8384
      @jamesblock8384 Před 4 lety +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.

  • @cheldap-softcheldap-soft900

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

  • @RafaelSantos-pq4od
    @RafaelSantos-pq4od Před 6 lety

    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

  • @javadziaebrahimi3568
    @javadziaebrahimi3568 Před 5 lety +1

    awesome as always

  • @Caelio
    @Caelio Před 2 lety

    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.

  • @sreeharsha75
    @sreeharsha75 Před rokem

    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.

  • @kadiryumlu
    @kadiryumlu Před 2 lety +1

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

    • @Squad2ND
      @Squad2ND Před 7 měsíci

      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.

  • @SunsetRacer
    @SunsetRacer Před 6 lety

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

  • @Donaldo
    @Donaldo Před 5 lety

    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?

  • @tankki1583
    @tankki1583 Před 4 lety

    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'

  • @ollerandres
    @ollerandres Před 6 lety +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 Před 5 lety

      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.

  • @muhammadafzal237
    @muhammadafzal237 Před 2 lety

    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.

  • @eduardodelagarza3318
    @eduardodelagarza3318 Před 5 lety +1

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

  • @kyumamorita
    @kyumamorita Před 5 lety

    easy to understand. good job!!

  • @raphaelabadie2518
    @raphaelabadie2518 Před 4 lety

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

  • @inescherif5385
    @inescherif5385 Před rokem

    thank u it helps me a lot

  • @moomoomamoo
    @moomoomamoo Před 5 lety

    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.

  • @eduardorabanal2803
    @eduardorabanal2803 Před 5 lety

    awesome video bro, thank you very much

  • @whatthefunction9140
    @whatthefunction9140 Před 3 lety

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

  • @hooligansofts7430
    @hooligansofts7430 Před 5 lety

    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?

  • @rachitkumarsingh3228
    @rachitkumarsingh3228 Před rokem

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

  • @user-wc1sm8cj8s
    @user-wc1sm8cj8s Před 3 lety +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.

  • @ray-lee
    @ray-lee Před 4 lety

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

  • @gamingfirst0tv
    @gamingfirst0tv Před 5 lety

    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.

  • @elvisfernandes4157
    @elvisfernandes4157 Před 6 lety +6

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

    • @cucco1
      @cucco1 Před 6 lety

      My thoughts exactly.

  • @muhdzulfadhlee
    @muhdzulfadhlee Před 5 lety

    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.

  • @kenjihikmatullah1060
    @kenjihikmatullah1060 Před 4 lety

    Nice explanation

  • @raghav4296
    @raghav4296 Před 5 lety

    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?

  • @youwillyou7905
    @youwillyou7905 Před 3 lety

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

  • @vOnez212
    @vOnez212 Před 6 lety

    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!

  • @DarkChasmGamers
    @DarkChasmGamers Před 3 lety

    For those watching in 2020, you can now do cross-collection queries

  • @zakariaarrim5493
    @zakariaarrim5493 Před 3 lety

    Thank you so much bro I was lost

  • @Neerajkumar-xl9kx
    @Neerajkumar-xl9kx Před 2 lety

    Wow loved it

  • @Manish-fm5iv
    @Manish-fm5iv Před 6 lety +3

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

    • @SquishySwishy
      @SquishySwishy Před 4 lety

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

  • @mattanderson2840
    @mattanderson2840 Před 2 lety

    Can someone link me the video that is episode 63 that is referenced please :)

  • @codewithluca
    @codewithluca Před 5 lety

    Great explaination

  • @joshbedo8291
    @joshbedo8291 Před 4 lety +1

    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.

  • @easysimple7191
    @easysimple7191 Před 2 lety

    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.

  • @soullesessess
    @soullesessess Před 4 lety

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

  • @yndrywjynsyn
    @yndrywjynsyn Před 6 lety

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

  • @NikosKatsikanis
    @NikosKatsikanis Před 4 lety

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

  • @yndrywjynsyn
    @yndrywjynsyn Před 6 lety

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

  • @avinashmphp
    @avinashmphp Před 6 lety

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

  • @JoeTechster
    @JoeTechster Před 6 měsíci

    Amazing!!

  • @arzz11
    @arzz11 Před 3 lety

    Please tell the name of into music or if it is your own music, give me payment link, I'll buy...

  • @SarShaGaming
    @SarShaGaming Před 6 lety

    Hey,
    What about lookup tables?
    How will you model those with firestore ?

  • @bstrnx
    @bstrnx Před 6 lety

    How do you model the data if you want to show only the tweets tweeted by users you follow?

  • @mohamedyoussef8835
    @mohamedyoussef8835 Před 2 lety

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

  • @hoangkha410
    @hoangkha410 Před 4 lety

    Please open the subtitles for each video.Thanks

  • @HaiNguyen-cf1ji
    @HaiNguyen-cf1ji Před 6 lety

    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?

    • @user72974
      @user72974 Před 5 lety

      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