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

前端 未结 4 666
面向向阳花
面向向阳花 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:30

    It depends entirely on the nature of the relationships.

    IF the relationship between a Person and a Student is 1 to N (one to many), then the correct way would be to create a foreign key relationship, where the Student has a foreign key back to the Person's ID Primary Key Column. Same thing for the Person to Teacher relationship.

    However, if the relationship is M to N (many to many), then you would want to create a separate table containing those relationships.

    Assuming your ERD uses 1 to N relationships, your table structure ought to look something like this:

    CREATE TABLE Person ( sin bigint, name text, PRIMARY KEY (sin) );

    CREATE TABLE Student ( GPA float, fk_sin bigint, FOREIGN KEY (fk_sin) REFERENCES Person(sin) );

    and follow the same example for the Teacher table. This approach will get you to 3rd Normal Form most of the time.

提交回复
热议问题