Results 1 to 4 of 4

Thread: Primary key

  1. #1
    Join Date
    Jan 2005
    Posts
    362

    Unanswered: Primary key

    I want to ask something simple for the design of a table.
    I have a table that I want to have two columns for primary key, a number and the year of the creation.
    But I have a foreign key for another table that represent the period that belong that record.
    It is a good idea to have that foreign key field with the "id" as primary key or it is better to create a new field "year" ?
    Dimis

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Do not store the same information more than once (unless it is a Data Warehouse you are building). If "createion year" is stored in another table, I'd leave it there; just make sure it is related to "this" table (and it seems that it is, as you've mentioned "ID" column).

    You've said that you'd like to have a composite primary key (made up of more than one column). Is it really a PRIMARY KEY? Would you, perhaps, rather leave your primary key as it was (for example, an ID column) and create UNIQUE INDEX instead?

  3. #3
    Join Date
    Jan 2005
    Posts
    362

    Key

    As I understand too I do not need to include that column at primary key, even not to create it but it could be good if the period at the other period will be deleted (maybe not the case)

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    another thing to consider it to save a single date. Using this date, you can determine the year, month, quarter, period, anything you want. Your should never do something like just storing the year (for example). It is useless for any other task.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •