The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Primary key x Foreign key

Primary key x Foreign key

Super Learner
1
Vote
1
Answer

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 Answer

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

Thank you. So, although this is not a formal requirement, by means of practice, in most of the cases it is, right?

3 weeks
×
LAST CHANCE
Ready to Learn Data Science?
50% OFF