Laravel: BelongsTo vs Polymorphic? Let's Test!

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 33

  • @Atiradeonvideo
    @Atiradeonvideo 2 роки тому +2

    Always really good when a video is reflecting a day-to-day kind of situation at work. These decision (database structure, coding style) are happening a lot under the hood and a good developer should always address all these long-term considerations as you do here.
    Nice job!

  • @ejaadhulab8924
    @ejaadhulab8924 2 роки тому

    this is exactly what I am looking for. Thank you very much for sharing daily tips. Although the tutorial is old the content is not outdated.

  • @leonardoldr
    @leonardoldr 3 роки тому +3

    I know it's an old video, but in fact for an application that have to be maintained for a long time polymorphic seems to add the inconvenience of "guessing". Pretty much any developer knows what a foreign key is, but maybe just the advanced will realize the polymorphic.
    Also, would be fine to have a real-world test with the "real" database modelling with 3 tables vs 1 poly and each of them with millions of rows.
    But, as always very helpful, your videos are helping me a lot! :)

  • @3mro_coding
    @3mro_coding 3 роки тому

    This review video didn't get what it deserves. Am sharing this to all social networks this really quality content. Thanks for sharing.

  • @ashrafuzzamashraf8854
    @ashrafuzzamashraf8854 Рік тому

    Good benchmark video. Thanks

  • @maiconmva
    @maiconmva 4 роки тому +10

    but if you add a index key in class name column, will be much faster

  • @Jossnaz
    @Jossnaz 3 роки тому +1

    I appreciate your videos.
    I keep thinking as well that you focus a bit too much about "shorter syntax". Just because you can mke it shorter, doesnt mean you should. Readability is king, reading the couple ifs vs that string replace? For me ifs way easier to read. As well imagine you need translations. Your ide will help you find the references. And its easy to add another if. For example i dont like laravel resources a lot either because i like to be able to search for a problematic http call in my code. If you use resource you wont find it any more. Its shorter, but at what cost?

  • @maxralph01
    @maxralph01 Рік тому

    Very informative!

  • @shire7949
    @shire7949 3 роки тому

    Very valuable information

  • @cxian
    @cxian Рік тому

    What do you call on that Laravel developer console on the bottom of the page? Is that part of the Quick Panel?

    • @LaravelDaily
      @LaravelDaily  Рік тому

      composer require barryvdh/laravel-debugbar

    • @cxian
      @cxian Рік тому

      @@LaravelDaily Thank you sir!

  • @sonant_bwolfe
    @sonant_bwolfe 4 роки тому +1

    "This table full of strings is bigger than this table full of integers, I'm not sure why when I export both as utf8 text they're the same size" :D

  • @ahmedabdnaser1582
    @ahmedabdnaser1582 3 роки тому

    thank you, this video is very informative. keep going

  • @helluci6449
    @helluci6449 Рік тому

    6:30 also breaks the SOLID principles, right? Is there a way to prevent that?

  • @Construction-agencyCoUk
    @Construction-agencyCoUk 4 роки тому +1

    fantastic video - thanks 🙏

  • @thatsenam9183
    @thatsenam9183 3 роки тому

    Really Helpful

  • @evilwizard7931
    @evilwizard7931 Рік тому

    Does having multiple foreign key fields in this case break normalisation? I mean how can the database enforce that only 1 of the fields is populated & the other 2 are null?
    Also, A big thanks you for your tips & knowledge sharing

    • @LaravelDaily
      @LaravelDaily  Рік тому +1

      From what I understand, yes, polymorphic relationship breaks the normalization. But normalization isn't a sacred rule, in my opinion.

    • @evilwizard7931
      @evilwizard7931 Рік тому

      @@LaravelDaily I meant the other way, the database can enforce the relationship with the other tables, but how can the table containing multiple foreign key fields as primary relation. What is stopping a record being linked to all 3 other tables is what I'm asking I guess & has no bearing on Laravel/Eloquent. It's as sacred as SOLID, something to strive for, but don't break your back doing it, even the fundamental laws of the universe do it the easy/lazy way :)

    • @LaravelDaily
      @LaravelDaily  Рік тому +1

      Well, polymorphic relationship is NOT the database relationship, it doesn't have foreign keys or other DB level constraints. If you go for polymorphic, you kinda forget DB constraints and rely on Laravel functionality.

  • @bunwong9718
    @bunwong9718 4 роки тому +1

    What is the name of the DEVTOOL bar under the browser?

  • @nabeelyousafpasha
    @nabeelyousafpasha 4 роки тому

    Do you feel it unnecessary to query multiple times via WITH method rather than JOIN? However some may find join slower but we can manipulate data at db level in a single query using multiple tables with JOIN. DB transactions cost lesser (if i am right). What are your suggestions regarding this

    • @PovilasKorop
      @PovilasKorop 4 роки тому +1

      It's a personal preference, I tend to use all Eloquent possibilities and not Query Builder with join(), whenever possible. Doing it directly with join() sometimes may be quicker, sometimes not. It depends on the situation.

  • @devmaster8923
    @devmaster8923 4 роки тому

    how to install the bar like yours? where you can see the result?

    • @PovilasKorop
      @PovilasKorop 4 роки тому +4

      It's called Laravel Debugbar, Google how to install it

  • @iordanistsapanidis4021
    @iordanistsapanidis4021 4 роки тому +1

    Why not use db queries?? easier with() than join() but faster

  • @TheBaltLT
    @TheBaltLT 10 місяців тому +1

    what value your talking head adds to this tutorial apart distraction?

    • @wayne_xyz
      @wayne_xyz 10 місяців тому

      So that you can see and remember the actual human being who is making efforts to teach everyone who needs teaching. You ungrateful asshole