what is primary key,unique key, foreign key? can u teach me
in simple language?
Answer Posted / rajesh
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 ? | 19 Yes | 7 No |
Post New Answer View All Answers
List various types of log-based recovery in DBMS.
Explain various types of locks in a transaction? Which is better and why?
What are the validations performed on the source data? If there are junk data available in the source data, how to eliminate it?
What is database collection?
Explain phantom deadlock?
What are the types of indexes that are present inside a database?
What is the importance of database partitioning?
What is database client?
i have windows-xp processor with P4 system. whenever I tried to download foxpro for windows 2.6 on windows XP, my operating system failed to install foxpro for windows 2.6.please. how could i download , install & run foxpro for windows 2.6 easily on windows XP ?
What is the relationship that exists inside in E-R diagram?
What is lagging in DBMS ?
What is a database string?
What is a Transformation?
How to do Data integrity testing? Who does this testing (Developer or tester)?
How to do Stored procedure testing? Who does this testing (Developer or tester)?