What is a superkey?(better,with examples).what is the difference between composite key and a superkey? composite key= compound key?

Superkey - A superkey is defined in the relational model as a set of attributes of a relation variable (relvar) for which it holds that in all relations assigned to that variable there are no two distinct tuples (rows) that have the same values for the attributes in this set.

please read more here, here, here .

commented: Aye :) +14

I have read two of links you have given ,before asking this question here,but they were too confusing.......
please provide me with a simple example if possible

Given table: EMPLOYEES{employee_id, firstname, surname, sal}

Possible superkeys are:

{employee_id, firstname}
(employee_id, firstname, surname, sal}

Only the the minimal superkey - {employee_id} - will be considered as a candidate key.

read more here.

1.Which means ,a primary key can be considered as a superkey too?
2.if we get

[U]emp ID[/U]   [U] firstname [/U] 
 12          harry
 13          harry

What is the superkey? 12,harry or 13,harry?

yes, it can be if it a combination of more than one field and may be one filed is enough to uniquely identify the records.

in your case super key is not (12,harry) or (13,harry)

it is (emp_ID, firstname)

and since data in firstname column is exactly same , that is not going to help in uniquely identifying the records.

So only the emp_id is enough for the unique identification of record.

1-If we got (12,harry) or (13,fedrick) ,we can take superkey as {emp_ID,firstname } or {emp_id} or {first name} or ALL?

2-if we have two column as the super key,it will also be a composite key,right?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.