0

In the process of decomposition to normalize a relation. If I reach the point where all attributes in a relation depend on the primary key, can I assume that they will all depend entirely on the different candidate keys? If that is not a case can you please give me an example of a case where all attributes depend on the primary key, but some of them depend on the part of other candidate keys.

I'm starting learning databases

BND
  • 612
  • 1
  • 13
  • 23

1 Answers1

1

Surrogate primary IDs make an example really easy:

(row_id PK, student_id, course_id, student_name)

where row_id and (student_id, course_id) are candidate keys and student_id -> student_name. Of course the row_id trivially determines any other attributes if it's an auto-incremented number.

reaanb
  • 9,806
  • 2
  • 23
  • 37
  • Ok, things are getting clear. Just one point. I don’t see any utility for surrogate keys in case that we already have (student_id) that can be a primary key. Are only the cases with surrogate keys out of my statement? Thanks – BND Jul 24 '15 at 10:30
  • No, this can happen whenever a table has multiple candidate keys of which at least one is composite. Consider the final example on Wikipedia's 2NF page: https://en.wikipedia.org/wiki/Second_normal_form#2NF_and_candidate_keys. I could also construct other examples using dates, SSNs, cartesian/polar coordinates as candidate keys, etc. – reaanb Jul 24 '15 at 20:19
  • Ok thank you for your help. I now have to check for each candidate key – BND Jul 26 '15 at 15:56