Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    18

    Surrogate keys and 3NF

    I have a table:

    linkId (PK)
    projectId
    employeeId
    dateJoined

    linking a project table and an employee table and stating when each employee joined each project they joined.

    Now, dateJoined is dependent on projectId and employeeId, however the surrogate key is the PK of the table. is the dateJoined <-> employeeId+projectId relationship a transitive dependency for the purpose of determining 3NF and if so, is this table to be considered denormalized?

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171

    Re: Surrogate keys and 3NF

    Originally posted by naz
    I have a table:

    linkId (PK)
    projectId
    employeeId
    dateJoined

    linking a project table and an employee table and stating when each employee joined each project they joined.

    Now, dateJoined is dependent on projectId and employeeId, however the surrogate key is the PK of the table. is the dateJoined <-> employeeId+projectId relationship a transitive dependency for the purpose of determining 3NF and if so, is this table to be considered denormalized?
    According to your definition, I would say your table has 2 candidate keys:
    1: linkId
    2: projectId, employeeId
    Therefore, dateJoined depends directly on BOTH candidate keys, and there is no transitive dependency, the table is in 3NF.

    However, I would question:

    a) Why create a surrogate key when you have already identified a perfectly good natural one? Unless this linkID is going to appear as a foreign key in other tables, what benefit does it confer?

    b) Is your assumption correct that "dateJoined is dependent on projectId and employeeId"? Can an employee not join a project, leave it, then join it again? In which case, dateJoined becomes part of the key (projectId, employeeId, dateJoined).

  3. #3
    Join Date
    Jul 2003
    Posts
    18
    The example was highly simplified, the assumption was that an employee would only join once.

    WRT to the surrogate key, I prefer use of employeeId+projectId as the PK, I was asking for purely theoretical and academic reasons.

    Thankyou for your answer, it was exactly what I was after.

Posting Permissions

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