Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need help with Easy Problem about Candidate/Primary/Super Keys

jamezy187jamezy187 Member Posts: 2
Im having a little trouble with the following problem

CREATE TABLE Report(
Id INTEGER,
SSN CHAR(10),
ReportCode VARCHAR(25),
Term VARCHAR(25),
Grade CHAR (2),
CHECK(Grade in ('A','B', 'C')),
UNIQUE(SSN, ReportCode, Term),
PRIMARY KEY(Id, ReportCode, Term)
)

My questions are:

1. are the candidate keys (SSN, ReportCode, Term) ?

2. is the primary key SSN or Id. Im not sure since I read that primary key should be one of the candidate keys, but SSN is not listed where it says Primary key.

3. are the superkeys (Id, ReportCode, Term) ?

Thanks for any help, i really appriciate it. Im still trying to get the hang of all this.

Comments

  • nneomanneoma Member Posts: 61
    : Im having a little trouble with the following problem
    : CREATE TABLE Report(
    : Id INTEGER,
    : SSN CHAR(10),
    : ReportCode VARCHAR(25),
    : Term VARCHAR(25),
    : Grade CHAR (2),
    : CHECK(Grade in ('A','B', 'C')),
    : UNIQUE(SSN, ReportCode, Term),
    : PRIMARY KEY(Id, ReportCode, Term)
    : )
    :
    : My questions are:
    :
    : 1. are the candidate keys (SSN, ReportCode, Term) ?
    :
    : 2. is the primary key SSN or Id. Im not sure since I read that primary key should be one of the candidate keys, but SSN is not listed where it says Primary key.
    :
    : 3. are the superkeys (Id, ReportCode, Term) ?
    :
    : Thanks for any help, i really appriciate it. Im still trying to get the hang of all this.
    :


    well, i really do not know what a super key is but if i'm right, a candidate key is a key that could also be used as a primary key if the present primary key is not used and a primary key is a key or column that uniquely identifies each row in a table.
    from the create table statement, what we have is a composite primary key i.e a primary key composed of different columns in this case - id, ReportCode and Term. this means that each row must have a unique combination of these three items. thus, we can have the following rows

    id ReportCode Term
    10 AC1234 First
    10 AE3784 First

    as you can see, the id and term columns have the same values. however, this is not a violation of the primary key constraint as we are considering a composite primary key. thus, all the values in these three columns must be the same in two or more rows before we can have a violation of the primary key constraint.

    as for the candidate keys, we also have a composite candidate key made up of the SSN, ReportCode and Term columns. since they have a unique constraint imposed upon them, the same rules as above apply to them.

    i hope i was of help. please let me know.
  • nneomanneoma Member Posts: 61
    : Im having a little trouble with the following problem
    : CREATE TABLE Report(
    : Id INTEGER,
    : SSN CHAR(10),
    : ReportCode VARCHAR(25),
    : Term VARCHAR(25),
    : Grade CHAR (2),
    : CHECK(Grade in ('A','B', 'C')),
    : UNIQUE(SSN, ReportCode, Term),
    : PRIMARY KEY(Id, ReportCode, Term)
    : )
    :
    : My questions are:
    :
    : 1. are the candidate keys (SSN, ReportCode, Term) ?
    :
    : 2. is the primary key SSN or Id. Im not sure since I read that primary key should be one of the candidate keys, but SSN is not listed where it says Primary key.
    :
    : 3. are the superkeys (Id, ReportCode, Term) ?
    :
    : Thanks for any help, i really appriciate it. Im still trying to get the hang of all this.
    :


    well, i really do not know what a super key is but if i'm right, a candidate key is a key that could also be used as a primary key if the present primary key is not used and a primary key is a key or column that uniquely identifies each row in a table.
    from the create table statement, what we have is a composite primary key i.e a primary key composed of different columns in this case - id, ReportCode and Term. this means that each row must have a unique combination of these three items. thus, we can have the following rows

    id ReportCode Term
    10 AC1234 First
    10 AE3784 First

    as you can see, the id and term columns have the same values. however, this is not a violation of the primary key constraint as we are considering a composite primary key. thus, all the values in these three columns must be the same in two or more rows before we can have a violation of the primary key constraint.

    as for the candidate keys, we also have a composite candidate key made up of the SSN, ReportCode and Term columns. since they have a unique constraint imposed upon them, the same rules as above apply to them.

    i hope i was of help. please let me know.
Sign In or Register to comment.