Both Primary & Unique keys are Indexes.
Index - An index is a structure in a table that orders the data. It allows the database to access data quickly (In MySQL its implemented using B-tree algorithms).
Primary Key - This is an index that cannot be NULL, Primary Keys are used in building relationships between tables in a database. (an index is automatically created on the primary key). The difference between primary and ordinary keys is that there can be multiple keys, but only one primary key.
Unique Key - Unique and Index are same, the difference is, in Unique, duplicate are not allowed in any circumstances and that is enforced by database server. Primary key(s) qualify to be Unique on basis of their uniqueness.
In case, your table has 2 primary keys means that the 2 fields together form one unique key. Each field by itself may have repeating values, but both primary keys combined together must be unique.
Blog on things around me - Quality Management, Free & Open Source Software, Gadgets, Utilities...
Subscribe to:
Post Comments (Atom)
Total Pageviews
Popular Posts
-
" Is you primary platform Microsoft based? Do you work with Microsoft products most of the time? Are most of your Google Searches Micro...
-
I tried reaching Google Adsense via google.com/adsense in Google Chrome, and I was prompted with the this message :) Amazon.com Get Technica...
-
Always give your 100% to work... :) [received in an email]
-
life in balance : life in balance Add me on Twitter! Come follow my daily antics, links, tips and more @rajneeshgarg on Twitter!
-
A highly useful guide on software pricing by Neil Davidson is available as e-book on author's website . A printed copy can be purchased ...
3 comments:
Nicely explained, I guess the same would stand out for DB2 as well...
Refer following
href="http://mainframewizard.com/content/difference-between-primary-key-and-unique-key">Difference between primary and unique key
That's add value to original post. worth including in my list of differences between primary and unique key.
I have look for this explanation all around the Internet.
However not new to me, more than 30 years ago using relational database tables, let me tell to whom reads this.
Primary Key and Unique Keys in the context of the table are equal. Primary keys were created for relational tables, where you relate one table with the other without the need to link fields on each table.
Post a Comment