How to find candidate keys here in DBMS?

  • Comp Sci
  • Thread starter shivajikobardan
  • Start date
In summary, the given relation has a primary key of Sname and Sno, with functional dependencies of Sno,Pno -> Qty, Sname,Pno -> Qty, Sno -> Sname, and Sname->Sno. To find the other primary key, you can use a candidate key calculator. However, there may still be some uncertainty due to missing information.
  • #1
shivajikobardan
674
54
Homework Statement
find candidate keys
Relevant Equations
Normalization in database
Consider a relation given below SP(Sno,Sname,Pno,Qty). Here Sname is considered unique for each Sno. So, FD of above relation is:

Sno,Pno -> Qty
Sname,Pno -> Qty
Sno ->Sname
Sname->Sno

Sname,Sno is one primary key(it's worded in question). What's the other? How to find it is my question. I've heard about taking closures but here there are 2 attributes in the LHS so I can't see a way to do closures.
 
Physics news on Phys.org
  • #2
It's hard to say much without more information, but I have some questions. You say that "Sname is considered unique for each Sno", but that does not necessarily mean that Sno is unique for each Sname. Is that true?
Does 'S' mean supplier? Does 'Sno' mean the Supplier part number for a part, or is it a number that you have given uniquely to each supplier?
Why do you need both Sname and Sno for a primary key?
Are you sure about Sname ->Sno? Are you saying that there can't be things from two different suppliers with the same name but different part numbers?

IMO, there is a lot left to guess at.
 

1. What are candidate keys in DBMS?

Candidate keys in DBMS are attributes or combinations of attributes that uniquely identify each row in a table. They are important because they help maintain data integrity and ensure that there are no duplicate rows in a table.

2. How do I identify candidate keys in a database table?

To identify candidate keys, you need to analyze the data in the table and determine which attributes or combinations of attributes can uniquely identify each row. This can be done by looking for attributes with unique values or by using functional dependencies.

3. What is the difference between a primary key and a candidate key?

A primary key is a candidate key that has been chosen as the main identifier for a table. It is unique and cannot have null values. Candidate keys, on the other hand, are all potential options for a primary key.

4. Can a table have more than one candidate key?

Yes, a table can have multiple candidate keys. In fact, it is common for a table to have several potential candidate keys. However, only one of these candidate keys can be chosen as the primary key.

5. How do I choose the best candidate key for a table?

The best candidate key for a table is one that is unique, non-null, and stable (meaning it does not change frequently). It should also be easy to remember and understand. If there are multiple options, the primary key should be the one that is most commonly used in queries and joins with other tables.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
729
  • Engineering and Comp Sci Homework Help
Replies
1
Views
627
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
646
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
652
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
Replies
12
Views
1K
  • Feedback and Announcements
Replies
6
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
940
  • Special and General Relativity
Replies
10
Views
2K
Back
Top