HOBALL 筆記簿

November 3, 2008

MySQL – Primary Key, Unique, Index

Filed under: SQL — Tags: , , , — hoball @ 1:06 pm

Not really a formal definition, but here it is:

Primary Key – Key to the specific record, tells you what uniquely identifies that record
Index – one of more fields indexed to improve access time
Unique Index – type of index, means that a field or group of field is unique, so no other record can have the same one

Note that “primary” is called PRIMARY KEY not INDEX.
KEY is something on the logical level, describes your table and database design (i.e. enforces referential integrity …)
INDEX is something on the physical level, helps improve access time for table operations.
Behind every PK there is (usually) unique index created (automatically).

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: