Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
shootdaj
Starting Member
3 Posts |
Posted - 2009-12-08 : 00:03:25
|
| This question is more about mathematical relations in general and not about SQL specifically, but it applies to SQL. My question is:Let's say a foreign key(FK) exists in relation R1 and FK references the primary key of R2. I understand that the domain of FK and the domain of the primary key of R2 are supposed to be the same. Does this imply that if there is a row in R2 that is NOT referenced by FK in R1, it is a violation? Or can R2 have any number of PK's without it actually being referenced. In other words, if a PK exists in a reference table, does it HAVE to be referenced by a FK, given that the FK in the another table refers to the PK of the reference table?Thanks,Anshul |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2009-12-08 : 00:16:37
|
| I read these...and my mind hurtsYou talk about CONSTRAINTSCONSTRAINTS...must be enforced...So if the SET of data has the possibility to POSSIBLY CONSTRAIN the data, then Yes.BUT, Unless you ENFORCE the CONSTRAINTIT JUST DOESN'T MATTERhttp://www.youtube.com/watch?v=g3S_k1dRbXYSay it with meIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERIT JUST DOESN'T MATTERBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
shootdaj
Starting Member
3 Posts |
Posted - 2009-12-08 : 00:43:40
|
| I mean in the technical definition of a foreign key, what are the constraints? I know that referential integrity constraint must hold for a foreign key in which the thing being referenced must exist. My question is does it also hold the other way around? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
shootdaj
Starting Member
3 Posts |
Posted - 2009-12-08 : 02:09:13
|
| Thank you that's what I was looking for. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|