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)
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