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
-
Here is the list of Online Hindi Radio Stations. Copy the URL in your media player and enjoy !! 106.2 HUMFM - UAE ==> http://www.humfm.c...
-
Here are a few of the JDBC Performance pointers. Hopefully, there are a lot more, which you may be aware of, but not mentioned here. Care to...
-
There are four types of JDBC database driver: The JDBC/ODBC bridge driver (Type 1) A piece of native C-code that translates a JDBC call to ...
-
I just decied to look for a few commonly used UNIX command. A quick Google produces a lot more, but here are a list of more useful commands...
-
Always give your 100% to work... :) [received in an email]
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