1
Views
4
Comments
Relationships Between Entities
Question
Hi all,

I am a newbie to the Agile Platform development, actually only started to explore it yesterday. Was going through the tutorial topivc 'How to relate database tables with foreign keys', but failed to make sense out of how the two tables (Company and Contact) described relate to each other.

There is a foreign key attribute called CompanyID in the table Contact but how does it link to the table Company since there is no such an attribute in the Contact table. Could someone please assist me in explaining how this is done.

Thank you.
Tables.JPG
2011-06-15 10-51-52
Cipriano Teibão
Hello,
 
What do you mean there is no such an attribute in the Contact table? The contact table has a CompanyId attribute where you store the company ID, and in the company table you have the id. If you put for example CompanyId=5 on a contact, then that contact will be related with the company with id=5.
2018-03-08 20-43-12
Robert Chanphakeo
@Tom

Your entity relationship diagram shows that 1 company can have many contacts.

COMPANY 1.* CONTACT.
(company has many contacts)

"There is a foreign key attribute called CompanyID in the table Contact but how does it link to the table Company since there is no such an attribute in the Contact table. Could someone please assist me in explaining how this is done."

The contact entity table has a foreign key "CompanyId"
UserImage.jpg
Tom Dicks
Yes, there is an Id attribute in the Company table, but I thought this is an automatically generated number. Can I change that number and put my own that I will know when entering records of the Contact table?

Thank you all.
2018-03-08 20-43-12
Robert Chanphakeo
@Tom

By default  when a identifier key/primary  key is created it is an interger datatype with auto numbering enabled.

You could set the number on your own however it is adviced that you have the database auto number the primary key id for you.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.