Solved

Can a PK be an FK as well ?

Posted on 2007-11-15
3
1,096 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this tutorial viewers will learn how to use the align and distribute tools in Illustrator. Open a document with multiple shapes to be aligned: Open the Align window by going to Window > Align or using the shortcut icons on the top bar of Illustra…
In this tutorial viewers will learn tricks for more effective scaling of vectors in Illustrator Open a document with vectors to be scaled in Illustrator: Normally, items do not keep their proportions when scaled. To fix this, hold down the shift key…

758 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

17 Experts available now in Live!

Get 1:1 Help Now