primary key vs unique index

Posted on 2007-10-07
Last Modified: 2008-01-09
I have 2 tables and i want to retrieve data from them and combine data to do some processing
I haven't made any column as PRIMARY yet ..

what is better to way do, shud i make col. as PRIMARY KEY in the tables separately or can i also make UNIQUE INDEX .. is unique index similar to making primary key ..

Question by:max_dub

    Author Comment

    if i am not clear on question, please let me knw.. i am just getting to knw db's
    LVL 42

    Accepted Solution

    You always want a primary key; you get a unique index by default.  Primary key is a logical constraint that is implemented with a unique index.  The advantage of the primary key is that it does not allow nulls and it is referenceable by a foreign key constraint.  

    LVL 42

    Expert Comment

    PS. There is no additional overhead for the PK, just benefit.  

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now