How to Solve This Database Design Problem

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 21

  • @farzadmf
    @farzadmf 3 дня назад +4

    +1 on option 4; less headache in the long run

    • @DatabaseStar
      @DatabaseStar  3 дня назад +1

      Thanks for sharing!

    • @_MB_93
      @_MB_93 День назад +1

      +1, and if you want to run analytics just pipe these data through an ETL/ELT process and run aggregations on another data warehouse with designs suited for OLAP, so having more tables on OLTP database is not really a problem - just need some schemas and a good naming practice

  • @sfermigier
    @sfermigier 4 дня назад +4

    Some of these approchaes are implemented in some ORMs, like e.g. SQLAlchemy which supports three forms of inheritance:
    - single table inheritance - several types of classes are represented by a single table;
    - concrete table inheritance - each type of class is represented by independent tables;
    - joined table inheritance - the class hierarchy is broken up among dependent tables. Each class represented by its own table that only includes those attributes local to that class.
    Additionally, Django supports what they call "Generic Foreign Keys" and corresponds to your last solution.

    • @DatabaseStar
      @DatabaseStar  3 дня назад

      That's good to know how ORMs handle it. I'm not surprised - application code can handle this much easier than databases.

  • @GordonRoland
    @GordonRoland День назад

    Similar challenge earlier this year. Used technique virtually the same as option 3. Would have saved time and several brain cells if I had seen this first!

  • @hodadisbirhan652
    @hodadisbirhan652 4 дня назад +2

    I would like choose option1 then add simple checking constraint without going write store procedure to meet the requirment becuase storing comment in one place it is helpfull for reply and mentioning feature to incorporate it at one place and for performance optimization we can use view table

    • @DatabaseStar
      @DatabaseStar  3 дня назад

      Thanks for sharing what you would do, that's good to know. I'm not sure you can add a check constraint to ensure that only one of the columns is populated, but I could be wrong.

    • @DKDonno
      @DKDonno День назад

      You absolute can (ensure it via a check constraints) and it’s the most sane way to do it.

  • @FPI23
    @FPI23 22 часа назад

    If any of the approach stores a blank column even if it is a number then I am avoiding that. So option 1 and 2 are not for me. Option 3 is good but another thing I dont want is too much joins. So the best one for me would be Option 4.

  • @ahmad-murery
    @ahmad-murery 4 дня назад

    Call me crazy but I had to use the 5th method in a project where I had attachments table related to multiple content types (more content types still undetermined while developing the app).
    In the attachment table I added a reference_type and a reference_id
    Thanks Ben!

    • @DatabaseStar
      @DatabaseStar  3 дня назад +1

      Good to know it worked for you!

    • @ahmad-murery
      @ahmad-murery 3 дня назад

      @@DatabaseStar Well, I wasn't fully satisfied but yes it fulfilled the task

  • @AravindhKumar007
    @AravindhKumar007 3 часа назад

    In software engineering, it's always KISS - Keep It Simply Stupid designs that are mostly efficient and easier to maintain.

  • @عليالعصفوري-ط4ض
    @عليالعصفوري-ط4ض 8 часов назад

    I saied option 4 even before you display it caue it will reduce search time if you fetch only one of two type even maybe all types and offers independency

  • @moayed8081
    @moayed8081 4 дня назад +1

    Amazing video
    But What about Morph way?
    I think its the best in this case

    • @DatabaseStar
      @DatabaseStar  3 дня назад

      What do you mean by "morph way"?

    • @GawblyOG
      @GawblyOG 22 часа назад +1

      @@DatabaseStar i think they refer to laravel's morph types

    • @lfelizari
      @lfelizari 10 часов назад

      Option 5 is the polymorphic method.

  • @OZTutoh
    @OZTutoh 2 дня назад +1

    Should an SQL beginner even look at this video?

    • @KenyanNetHunter
      @KenyanNetHunter День назад +1

      From the commentator's profile photos, this is the stuff of legends, I reckon some of them wrote SQL 1.0 😅😂😂😂