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 / teju

PRIMARY KEY :
IN THE TABLE we can find only one record as
uniqely & also it is not null.

unique key:
uk is to search any record as uniquely& when it
is declared it should be only one null values.

Fk:
fk is to maintain the relations bet two tables
as an duplicate values.means to not null.
e.g
1> stud(stud_id,stud_name);
2> stud_det(stud_id,addr);
In this table stud_id is an pk & In the stud_det as
stud_id is used as an duplicate.

Is This Answer Correct ?    1 Yes 1 No

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

Answer / sathish

1)Primary key is unique key but foriegn key always refers
to
primary key.

2) Primary keys enforce entity integrity by uniquely
identifying entity instances. Foreign keys enforce.

3)Primary key is unique
primary key is not NULL and

foreign key is NULL
foreign key reference as Primary key in another table.

4) primary key is used to identify a row and it doesnot
allow
null values. It avoids duplication of rows.

whereas foreign key refers to a column or combination of
columns included in the defenition of referential integrity.


referential integrity by completing an association between
two entities.

Is This Answer Correct ?    1 Yes 1 No

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

Answer / uma maheswari

primary key:
IT IS THE MAIN KEY AND IT DOES NOT ALLOWS THE NULL VALUE...
Unique key:
IT IS SIMILAR TO PRIMARY KEY .IT ALSO DONT ALLOWS THE NULL VALUE.
foreign key:
IT IS USED TO REPRESENT THE PRIMARY KEY VALUE...

Is This Answer Correct ?    1 Yes 1 No

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

Answer / vinodkumar

Primary key:it is a key in which uniquely identify the
answer which is stored in the DBMS.A table contains a
primary key.

Foreign key:A key used in the table to represent the primary
key i.e when the primary key is used in a table of one topic
then the same name can be used as foreign key in another topic

Is This Answer Correct ?    1 Yes 1 No

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

Answer / sriniwaas41

dublicate values- means two same values not allowed

primary key:does not allow null values and does not allow
dublicate v
alues
-reapeated values and null values not allowed
-we can use primary key only once in a table

unique key:
-reapeated values not allowed as per primary key.
-but the difference is null values are allowed
-another difference is we can declare more thatn one
unique column in a table.primary is not allowed

Is This Answer Correct ?    1 Yes 1 No

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

Answer / mansi valani

A Foreign Key is a field in a relational table that matches
a candidate key of another table. The foreign key can be
used to cross-reference tables.
The foreign key identifies a column or set of columns in one
(referencing) table that refers to a column or set of
columns in another (referenced) table. The columns in the
referencing table must reference the columns of the primary
key or other superkey in the referenced table. The values in
one row of the referencing columns must occur in a single
row in the referenced table. Thus, a row in the referencing
table cannot contain values that don't exist in the
referenced table (except potentially NULL). This way
references can be made to link information together and it
is an essential part of database normalization. Multiple
rows in the referencing table may refer to the same row in
the referenced table. Most of the time, it reflects the one
(parent table or referenced table) to many (child table, or
referencing table) relationship.

The referencing and referenced table may be the same table,
i.e. the foreign key refers back to the same table. Such a
foreign key is known in SQL:2003 as a self-referencing or
recursive foreign key.

A table may have multiple foreign keys, and each foreign key
can have a different referenced table. Each foreign key is
enforced independently by the database system. Therefore,
cascading relationships between tables can be established
using foreign keys.

Is This Answer Correct ?    1 Yes 1 No

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

Answer / anbarasu

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 ?    0 Yes 0 No

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

Answer / navya

pk-it doesn't accept null values.there must be only one pk in table.
unique-it accept null values.there may be one r more unique keys in a table.
foreign-used to refer any key

Is This Answer Correct ?    0 Yes 0 No

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

Answer / janu

Primary Key:

A primary key is a field or combination of fields that
uniquely identify a record in a table, so that an individual
record can be located without confusion.
Foreign Key:

A foreign key (sometimes called a referencing key) is a key
used to link two tables together.

Is This Answer Correct ?    6 Yes 7 No

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

Answer / sandeep beniwal (master)

Primary key:- Primary key means main key. A primary key is
one which uniquely identifies of a table. Prrimay key does
not allow null values and duplicate values.
e.g:
empno empname status
10 dipender active
20 nisha inactive
30 vikas active
40 naveen active
Pimary key not like this:
10 dipender active
20 nisha inactive
30 vikas active
naveen active ........ (duplicate value)

Unique key:-A unique is one which uniquely identifies a row
of a table, but there is a difference like it will allow
only one duplicate values (In sql).

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 and helps making link

e.g
employee_table user_table
empID empname status userID userID empname
10 dipender active 1 1 dipender
20 nisha inactive 2 2 nisha
30 vikas active 3 3 vikas
40 naveen active 4 4 naveen

In the above relation, userID is there in employee_table
which
is a primary key of user_table. that means, userID is
refering the user_table.

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More Databases AllOther Interview Questions

Define stored procedure?

0 Answers  


What is Stored procedure ?

4 Answers   IBM, iGate, Inspira Technologies,


can we delete autodiff back up that we have set through sql server agent.

0 Answers   Indian Web Technology,


What are the tools used for backup and ticketing?

0 Answers   Alcatel-Lucent,


what is data set ?

1 Answers  






What is a sequence? Explain it with one example?

0 Answers   BirlaSoft,


Is it possible to update AS400 database record while reading it with no lock

1 Answers  


Explain various types of locks in a transaction? Which is better and why?

0 Answers   Agilent,


What does currency type mean in database?

0 Answers   Amazon,


What is sqlcode -923 ?

1 Answers  


There are three servers are run by Oracle, MS Access and .Net. What are the procedure fetching the values of two variables from two servers among these?

0 Answers  


characters of DBMS A) non redundant B) data independence C) increased security D) all the above

1 Answers   Accenture, XP,


Categories