Last answered:

07 Sept 2020

Posted on:

06 Sept 2020

1

Primary key x Foreign key

Hi, all!   My question basically is: a foreign key in a child table is necessarily a primary key in the parent table? Would it make a difference if this is a mandatory criteria or not?   Thank you!
1 answers ( 0 marked as helpful)
Posted on:

07 Sept 2020

1
This is a good question and let me try to answer this . a) Does the FK on child table always a PK on the parent table ? No, it does not have to be necessarily . If that is true , then the model is one to many relationship for sure But let us consider this model (Person----------------> Courses ) In this case, many people can enroll in a course ID and a course ID refers to many people However, in real world, these types of relationships become very inefficient and usually these are broken down into at least two one- many relationship But FK in child table should not be a pK necessarily in parent table . In most of the case, it is true by design

Submit an answer