Re: Identifying candidate keys and primary keys

From: JOG <>
Date: Sat, 19 Apr 2008 18:45:58 -0700 (PDT)
Message-ID: <>

On Apr 13, 10:29 am, "" <> wrote:
> Hello guys, this one is for one of my assignments. I want explanations
> and hints only.
> I'm still confused with the concepts of candidate keys and primary
> key. We have a patient medication form from an hospital with these:
> Heading: Patient number, Full name, Bed number, Ward number, Ward
> name.
> Then a table with this columns: drug number, name, description,
> dosage, method of admin, units per day, start date, finish date.
> I have to find all the candidate keys and primary keys. I think
> candidate keys are the minimal superkeys.
> I have found {Patient number, Ward number, Ward name}. I have excluded
> {Patient number, Ward number, Ward name, Full name} and {Patient
> number, Ward number, Ward name, Full name, Bed number} which are also
> superkeys but contain more attributes.

I think you have enough responses from the good peeps here at cdt to see that *as it stands* you cannot determine keys due to a lack of information. However you could write about what the keys would be, given certain assumptions. For example, it seems to be an entirely reasonable assumption that 2 patients will not share the same physical bed. However, we don't know from the info you have how a bed is uniquely identified, and this is crucial. For instance, even if we assume a patient only has one bed,

  • does each bed in the hospital have a unique number?
  • or does bed numbering restart in each Ward?

If the first of these is the case, then no two possible facts that would go in your table could have the same bed_number (because we can't have two people in one bed), and hence {Bed_number} would be a candidate key for that table. If the second was the case however, no two facts in the table could share the same Ward number and bed number combination, so {Bed_number, Ward_number} would be the key.

Remember that a candidate key is just an attribute (or set of attributes) where for any particular attribute-value, only a single row in the table ever has that attribute-value. It can also therefore be used to uniquely identify that row as a whole.

Good luck.

> This means that I have found only one candidate key, and this is also
> the primary key I have found (a composite).
> Since the question was "identify all the candidate keys" I thought
> maybe I dont really understand the concepts...
> thanks for any help.
Received on Sun Apr 20 2008 - 03:45:58 CEST

Original text of this message