• drew.allen - Tuesday, January 30, 2018 11:37 AM

    K. Brian Kelley - Tuesday, January 30, 2018 11:21 AM

    Another idea for a PK is a composite key (two columns) consisting of the year + the day of the year. There are some uses for this.

    I would just use the date itself.  It's only a single field instead of being a composite key.  It's more human readable.  I could see having an index on year/day of the year, but I would not make it the PK.

    Drew

    PK doesn't have to be human readable. And there's value to determining what happened on the Nth of the year over multiple years. Think about how you'd have to deconstruct the key, for instance, if you wanted to compare temperature highs over the last 40 years for the same day.  Yes, you could look at month and day columns, but it's easier if you have a single column, excepting leap years, of course. But that throws anything of this sort off. Therefore, it really depends on what you're trying to do here. 🙂

    K. Brian Kelley
    @kbriankelley