Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Foreign Keys Expand / Collapse
Author
Message
Posted Thursday, June 1, 2006 11:39 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, July 3, 2007 11:06 PM
Points: 3, Visits: 1
 If you don’t have a key, you don’t have a table!     
- Joe Celko
It is very nice article 
which one can easly understand
without deep knowlege of MSSQL.
Also basic concepts are explained very well !!!!!
 
 
Post #284316
Posted Friday, June 2, 2006 1:04 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, April 14, 2011 12:01 PM
Points: 6, Visits: 6
Good, terse explanation.

The only issue I'd have with it is the use of the terminology "Parent" and "Child" to describe the relationship between the primary key and the foreign key(s) that reference it. In the best methodologies I've seen, the terms "parent" and "child" are reserved for unusual situations where you have things that depend for their existence on other things. An example of this might be a line on an invoice - the invoice must exist for the line to exist, do the invoice would be the "parent" and the line the "child". With dissimilar things, such as drivers and racecars, you'd have two distinct entities that were related by a foreign key, but neither would be the "parent" of the other.

That's terminology, but it avoids confusion.
Post #284638
Posted Saturday, June 3, 2006 12:40 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 30, 2014 10:08 PM
Points: 1,038, Visits: 444

Fair comment from Roger.  Makes me think actually that the next step for the article would be many-many relationship as many people get that confused




Post #284694
Posted Wednesday, June 14, 2006 7:16 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 11:17 AM
Points: 5,589, Visits: 24,967

As usual I am a day late and a dollar short, but heck was a good, clear, concise tutorial on foreign keys.

Thanks for the effort you put into this ... and as suggested by some one else, would be nice if you took the challenge and attempted to 'explain' the many to many relationship.

Again - thanks

 



If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Post #287330
Posted Thursday, July 20, 2006 6:25 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, March 20, 2007 12:30 PM
Points: 24, Visits: 1

Thank you all for your suggestions!

Post #295840
Posted Thursday, May 31, 2007 5:48 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, November 13, 2008 9:13 AM
Points: 499, Visits: 76
To not use FKs in an OLTP with any level of complexity is just plain ignorant. There is no excuse for it, and you will just get badly burned. Amazingly enough, through my career I've had to fight developers, managers, and even other DBAs in order to install FKs on databases! It's incredible. In almost every case, they have grown to see the rewards by catching logic / data problems in testing with the FKs. Not to mention happy customers...
Post #370227
Posted Monday, June 11, 2007 10:24 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, January 9, 2012 3:37 AM
Points: 36, Visits: 352

No mention of trusted FK's? See http://sqlblog.com/blogs/hugo_kornelis/archive/2007/03/29/can-you-trust-your-constraints.aspx Handy to know, especially if you are lumbered with a db that exposes all data through very complex (and poorly performing )views!

Post #372950
Posted Thursday, November 1, 2007 3:02 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 27, 2010 9:23 AM
Points: 30, Visits: 93
Hi,

This is really a good article. I had an doubt about that i want to generate the insert statement script for moving the data from one db to another. Nearly 500 tables are there, i want to know how to prioritize the tables list. Becuase each and every tables are internally referenced. Can you please help out to fix the issue
Post #417428
Posted Thursday, August 20, 2009 6:25 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 5:55 AM
Points: 56, Visits: 287
Hi,

Can you help me out in updating such Foreign Key relationships. In one of my tables, i have a FK relationship refering to my primary key of the same table.

The Table called MacMaster has following columns:

MacID MacName ClusterID


the ClusterID here is a foreign key referencing the MacID(PK) of the same table.


MacID(identity column;PK) MacName ClusterID
1 Mac1 2
2 Mac2 NULL

I was trying to load this table from an another table having following column

MacName ClusterName
Mac3 Mac4
Mac4 NULL
Mac5 NULL

Kindly suggest me a method to load the above data to MacMaster Table.
Finally my MacMaster table should have something like this:

MacID MacName ClusterID
1 Mac1 2
2 Mac2 NULL
3 Mac3 4
4 Mac4 NULL
5 Mac5 NULL

Is this can be achieved through TSql or do i need to create a some kind of front end for it.Kindly Suggest

Regards,
Post #774701
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse