what is primary key,unique key, foreign key? can u teach me
in simple language?
Answer Posted / 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 View All Answers
give a simple example of physical and logical data independence
Does facebook use graph database?
Explain various types of locks in a transaction? Which is better and why?
List some advantages of dbms.
How concurrency problems effect the database?
can i use the commands "modify" and Change in DB2 to alter my column datatype and its name in a table?
Differentiate between delete and truncate table?
What is the difference between primary and candidate key?
What is the database url?
What is the use of default key?
What are the advantages of normalizing a database.
HOW PASS PARAMETERS FOLLOWING ORDER RPG-CL-RPG?
What are the disadvantages of views in a database?
Difference between sql and mysql?
What is ole db used for?