what is primary key,unique key, foreign key? can u teach me
in simple language?




Answers were Sorted based on User's Feedback



what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / firoz basha

Primary key - Primary key means main key
def:- A primary key is one which uniquely identifies a row
of a table. this key does not allow null values and also
does not allow duplicate values. for ex,
empno empname salary
1 firoz 35000
2 basha 34000
3 chintoo 40000

it will not the values as follows:
1 firoz 35000
1 basha 34000
chintoo 35000

Unique key - single and main key
A unique is one which uniquely identifies a row
of a table, but there is a difference like it will not
allow duplicate values and it will any number of allow
null values(In oracle).
it allows only a single null value(In sql server 2000)

Both will function in a similar way but a slight difference
will be there. So, decalaring it as a primary key is the
best one.

foreign key - a foreign key is one which will refer to a
primary key of another table

for ex,
emp_table dept_table
empno empname salary deptno deptno deptname

In the above relation, deptno is there in emp_table which
is a primary key of dept_table. that means, deptno is
refering the dept_table.

Is This Answer Correct ?    1164 Yes 93 No

what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / priya reddy

primary key- if a column is declared as priamry then there
wont be any repeated values in that column throughout that
table, as well as it wont take any null values and we can
use primary key only once in a table. but we can declare
combination of two columns as primary key.
unique- if a column is declared as unique then again there
wont be any repeated values in that column, but this will
take null values and even we can declare more thatn one
unique column in a table.
foreign key-if a column is declared with this key then we
have to use a reference ie we need to give the column which
will have the same values as this column and the table that
column belongs to.. this referced column of other table
will be the primary key of that table.

Is This Answer Correct ?    379 Yes 91 No

what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / kranthi

primary key: primary creates a clustered index on the
column and it doesn't allow null values.

unique key: unique key creates non clustered index by
default.it allows "one null value".

foreign key: A foreign key (FK) is a column or combination
of columns used to establish and enforce a link between the
data in two tables

Is This Answer Correct ?    212 Yes 76 No




what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / pinna

primary key is that key that can uniquenly identify the
values

Is This Answer Correct ?    182 Yes 68 No

what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / nitin bisht

PRIMARY KEY: A tabLe can aontain only one PRIMARY KEY. It
Doesn't allow null values, it is used as Foreign Key In
Another Table(like Reference Key).

UNIQUE KEY: A Table may Contain one or more UNIQUE
constraints. Its aloow only one null value . Use this key We
maintain unique vales in the table.

FOREIGN KEY: A key used in one table to represent the value
of a primary key in a related table. While primary keys must
contain unique values, foreign keys may have duplicates. For
instance, if we use student ID as the primary key in a
Students table (each student has a unique ID), we could use
student ID as a foreign key in a Courses table: as each
student may do more than one course, the student ID field in
the Courses table (often shortened to Courses.student ID)
will hold duplicate values.

Is This Answer Correct ?    123 Yes 43 No

what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / ganesan s

a key which is uniquely identified by a record is called
primary key.

Is This Answer Correct ?    120 Yes 55 No

what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / doraswamy

One table allows only one primary key but there is no
restriction for unique keys.
These two are same but one difference is unique key will
allow nulls.
Primary key create on a combination of mulitiple colums.

Foreign key is reference of another table primiary key. It
will not allow null values.

~Doraswamy

Is This Answer Correct ?    106 Yes 43 No

what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / kiran chandra sarkar

PRIMARY KEY: A table can contain only one PRIMARY KEY. It
doesn’t allow null values; it is used as Foreign Key in
another Table (like Reference Key).

UNIQUE KEY: A Table may contain one or more UNIQUE
constraints. It’s allowing only one null value. Use this
key we maintain unique vales in the table.

FOREIGN KEY: A key used in one table to represent the value
of a primary key in a related table. While primary keys
must contain unique values, foreign keys may have
duplicates. For instance, if we use student ID as the
primary key in a Students table (each student has a unique
ID), we could use student ID as a foreign key in a Courses
table: as each student may do more than one course, the
student ID field in the Courses table (often shortened to
Courses. student ID) Will hold duplicate values.

Is This Answer Correct ?    92 Yes 29 No

what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / nizamuddin

primery key is unique not null.
in a table only one primery key

Is This Answer Correct ?    29 Yes 14 No

what is primary key,unique key, foreign key? can u teach me in simple language?..

Answer / heena verma

Primary Key:- it is a contraint(checks) provided by DBMS.
if we want to make a coumn unique and not null then the
column is defined as primary key. it is used to create
relations among the tables.

Is This Answer Correct ?    55 Yes 43 No

Post New Answer



More Databases AllOther Interview Questions

Why merge statement is used inside the database?

0 Answers   ADITI,


What are the types of indexes that are present inside a database?

0 Answers   Abacus,


What is the role of tester in discovery(in Checklist)?

0 Answers  


What is the difference between oracle and MS Access?

0 Answers   Alcatel-Lucent,


what are different types of datasets? what are different characteristics or properties of those datasets? what are the advantages and disadvantages of each dataset on each other?

1 Answers   OVGU,






Integrity constraints means..? how many and what are they?

4 Answers   AZTEC,


Can you tell any two advantages of stored procedures?

0 Answers   Verifone,


What are the concurrency problems a database faces?

0 Answers   Amazon,


What is the use of default key?

0 Answers   Abacus,


What is the differnce between Order by and Group by

1 Answers  


You are creating a Index on EMPNO column in the EMPLOYEE table. Which statement will you use?

0 Answers   3i Infotech,


What are the tools used for backup and ticketing?

0 Answers   Alcatel-Lucent,






Categories