June 3, 2009 at 7:01 am
If i have a clustered index on a table withtout any PK, does it satisfy the purpose of PK.
June 3, 2009 at 7:13 am
Primary key enforces uniqueness and also doesnt allows NULL.
June 3, 2009 at 7:26 am
Tara (6/3/2009)
If i have a clustered index on a table withtout any PK, does it satisfy the purpose of PK.
The primary key in fact is a concept in relational databases. The objective of the PK is to have no repeated records in a table based on primary key fields. By the way, if you have a UNIQUE index containing some fields, it will satisfy the uniqueness criteria but you have to ensure that these fields can not contain null values. The fact of index being clustered or nonclustered is not relevant for the purpousses of PK.
June 3, 2009 at 8:42 am
that means both will have uniqueness but the only differnce is clustered index will allow NULL but PK doesnt.
June 3, 2009 at 8:51 am
if you have a UNIQUE index containing some fields
that means both will have uniqueness but the only differnce is clustered index will allow NULL but PK doesnt.
You need to define it as UNIQUE....
CLUSTERED means data is physicaly ordered in the table..Doesn't mean that it's unque.
June 3, 2009 at 8:56 am
Tara (6/3/2009)
If i have a clustered index on a table withtout any PK, does it satisfy the purpose of PK.
Simply put, no. They're not the same thing.
Clustered indexes, even unique clustered index, will satisfy many of the mechanical purposes of a PK, but it's not the same concept.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
June 3, 2009 at 9:06 am
Introducing Primary Key is enforcing business rules concept.(its more logical concept)
Enforcing Clustered indexes is in regard to your maintenance of your table(Searches, Sorting of ur table, more physical concept)
June 3, 2009 at 11:28 am
At the same time, primary key creates the clustered index automatically if no clustered index already exists
June 3, 2009 at 12:32 pm
bugop (6/3/2009)
At the same time, primary key creates the clustered index automatically if no clustered index already exists
That is not rigorously correct...
As many people has said, the primary key is a logical concept. When you set the primary key using the Management Studio visual interface then it enforces the primary key restriction creating a clustered index (if no clustered index already exists).
June 3, 2009 at 12:51 pm
FelixG (6/3/2009)
bugop (6/3/2009)
At the same time, primary key creates the clustered index automatically if no clustered index already existsThat is not rigorously correct...
As many people has said, the primary key is a logical concept. When you set the primary key using the Management Studio visual interface then it enforces the primary key restriction creating a clustered index (if no clustered index already exists).
That's the default behavior. You can specify "nonclustered" on a PK explicitly, in which case it will simply create a unique index, even if there's no clustered index on the table.
But now we're off into essoterica.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply