Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Re: Primary key & constraints


Message #1 by "Geoff Higgins" <geoff@v...> on Tue, 26 Jun 2001 09:04:02 +0100
Not like Ken Schaefer to only half answer someone's query so here's a bit
more info ...

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> : Can he also explain the difference between "simple" primary
> : key and constraints?
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Okay, here goes, a constraint is a way of keeping database integrity. With a
constraint, you set a rule on how the data can be checked so that you always
know that it cannot be changed in a way that would corrupt your data. ie. in
Access the Allow Zero Length when set to No is a constraint on that field
that no NULL values are allowed in that field.
A Primary key is actually a constraint that is set on a table in a database.
When you specify that a column or multiple columns in a table are a Primary
key for that table you are telling the DBMS (database management system)
then this column(s) must not have null values and that each must be unique.
You can only have one Primary key in a table but other columns may have the
properties of being Primary keys (not null, unique values). These are known
as Candidate keys.

Hope this gives a little insight but as Ken suggests BOLL is a good resource
as well as other resources on the web.

Geoff


> Subject: Re: Basic knowledge
> From: "Ken Schaefer" <ken@a...>
> Date: Fri, 22 Jun 2001 17:16:05 +1000
> X-Message-Number: 3
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> : From: "Bernhard Doebler" <programmer@b...>
> : Subject: [sql_language] Basic knowledge
> :
> : can one of you please be so kind to explain the differences
> : between clustered and unclustered indexes.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Did you look in Books Online?
> A clustered index means that the data is stored physically in that order
on
> the disk, making it easy to pull a number of sequential records. As well,
> the index entries point to the physical location on the disk where the
> record can be found.
>
> A non-clustered index merely points to the location in the clustered index
> where the record can be found. SQL Server then looks in the clustered
index
> for the physical location on the disk for the record
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> : Can he also explain the difference between "simple" primary
> : key and constraints?
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> A primary key identifies a record uniquely. A constraint is something
else -
> look in Books Online.
>
> Cheers
> Ken
>
>




  Return to Index