Entity Relationship Diagram. How does the IS A relationship translate into tables?

前端 未结 4 669
面向向阳花
面向向阳花 2021-02-05 09:46

\"My

I was simply wondering, how an ISA relationship in an ER diagram would transl

4条回答
  •  不知归路
    2021-02-05 10:43

    This answer could have been a comment but I am putting it up here for the visibility.

    I would like to address a few things that the chosen answer failed to address - and maybe elaborate a little on the consequences of the "two table" design.

    The design of your database depends on the scope of your application and the type of relations and queries you want to perform. For example, if you have two types of users (student and teacher) and you have a lot of general relations that all users can part take, regardless of their type, then the two table design may end up with a lot of "duplicated" relations (like users can subscribe to different newsletters, instead of having one M2M relationship table between "users" and newsletters, you'll need two separate tables to represent that relation). This issue worsens if you have three different types of users instead of two, or if you have an extra layer of IsA in your hierarchy (part-time vs full-time students).

    Another issue to consider - the types of constraints you want to implement. If your users have emails and you want to maintain a user-wide unique constraint on emails, then the implementation is trickier for a two-table design - you'll need to add an extra table for every unique constraint.

    Another issue to consider is just duplications, generally. If you want to add a new common field to users, you'll need to do it multiple times. If you have unique constraints on that common field, you'll need a new table for that unique constraint too.

    All of this is not to say that the two table design isn't the right solution. Depending on the type of relations, queries and features you are building, you may want to pick one design over the other, like is the case for most design decisions.

提交回复
热议问题