Solved

Can a PK be an FK as well ?

Posted on 2007-11-15
3
1,097 Views
Last Modified: 2008-03-23
Hello,

Can a PK be an FK as well ?

Thank you.
0
Comment
Question by:matthew016
3 Comments
 
LVL 20

Assisted Solution

by:steelseth12
steelseth12 earned 200 total points
ID: 20292600
foreign key of one table is the primary key of another table.
For the field to be the primary key of table A and the foreign key of table B ... No. Foreign key needs to take the values from table B.
0
 
LVL 1

Accepted Solution

by:
kiwi_nz earned 300 total points
ID: 20295410
yes a pk can be an fk - however this must be done in a special way. The trick is you must have two foreign keys that then composite into a Primary key - this is useful for when tables would otherwise have a many to many relationship you can put an intermediary table in between them and use the PK from each primary table as an FK in the intermediary table thereby creating a one to many - int table - many to one relationship.

Personally I dislike this method and always give the intemediary table a primary key and then add the two FK's thus making sure every single record in every single table is unique
0
 
LVL 9

Author Comment

by:matthew016
ID: 21189650
The answer was just yes, no special way needed
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
In this tutorial viewers will learn how to apply a non-rasterized, vector-scalable texture to a vector using opacity texture masks in Illustrator Open a vector in Illustrator. Black and white vectors work best, but this effect can also be used to ad…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now