CPGDeveloper
Board Regular
- Joined
- Oct 8, 2008
- Messages
- 189
Hello~
DB Design question -- say I have a primary table, tCompanies, where the primary key is CompanyID.
And I have another table, say tCompanyMetrics, where every field in that table has a one to one relationship with CompanyID.
In tCompanyMetrics, do I need both a primary key field and a foreign key field? Cannot I put a field in tCompanyMetrics also called CompanyID and have that field as both the primary key and foreign key.
This stackoverflow article seems to suggest this is fine -
Is it fine to have foreign key as primary key?.
But before I build this, I wanted to see if there is another school of thought about this or if I'm missing something here. Thanks!
DB Design question -- say I have a primary table, tCompanies, where the primary key is CompanyID.
And I have another table, say tCompanyMetrics, where every field in that table has a one to one relationship with CompanyID.
In tCompanyMetrics, do I need both a primary key field and a foreign key field? Cannot I put a field in tCompanyMetrics also called CompanyID and have that field as both the primary key and foreign key.
This stackoverflow article seems to suggest this is fine -
Is it fine to have foreign key as primary key?.
But before I build this, I wanted to see if there is another school of thought about this or if I'm missing something here. Thanks!