Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q1 Explain the difference among the terms Primary Key, Candidate Key and Super K

ID: 3800014 • Letter: Q

Question

Q1
Explain the difference among the terms Primary Key, Candidate Key and Super Key with suitable examples.

Q2
Consider the following schema:
Supplier(sid: integer, sname: string, address: string)
Part(pid: integer, pname: string, colour: string)
Catalog(sid: integer, pid: integer, cost: real)
The relation Supplier stores suppliers and the key of that relation is sid. The relation
Part stores parts, and pid is the key of that relation. Finally, Catalog stores which
supplier supplies which part at which cost. The key is the combination of the two
attributes sid and pid.
A. Write the queries in relational algebra for the following:
1. Find the names of suppliers who supply some red part.
2. Find the IDs of suppliers who supply some red or green part.
3. Find the IDs of suppliers who supply some red part or are based at 21 George
Street.
4. Find the IDs of suppliers who supply some red part and some green part.

B. For each of the following relational algebra queries, write in English what they mean.
1. sname(colour=’red’(Part)      cost<100 (Catalog)     Supplier)
2. sname(sid(colour=’red’(Part)    cost<100 (Catalog))    Supplier)



Explanation / Answer

Q1

Explain the difference among the terms Primary Key, Candidate Key and Super Key with suitable examples.?

I'll take example of AN worker table:

Employee (

Employee ID,

Full Name,

SSN,

DeptID

)

1. Candidate Key: area unit individual columns during a table that qualifies for singularity of all the rows. Here in worker table EmployeeID & SSN area unit Candidate keys.

2. Primary Key: area unit the columns you select to take care of singularity during a table. Here in worker table you'll opt for either EmployeeID or SSN columns; EmployeeID is desirable alternative, as SSN may be a secure worth.

4. Super Key: If you add the other column/attribute to a Primary Key then it become a brilliant key, like EmployeeID + Full Name may be a Super Key.

A super secret's any set of attributes specified the values of the attributes (taken together) unambiguously determine one entity within the entity set.

A candidate secret's a stripped super key -- a brilliant key with no redundant attributes. In alternative words, if anybody of the attributes is removed, the set of attributes that stay not type a superkey.

A primary secret's one in all the candidate keys, selected by the information designer.

Every primary secret's conjointly a candidate key; each candidate secret's conjointly a superkey, however not contrariwise.