Index and or constraint

  • gvoshol 73146 - Thursday, April 6, 2017 5:39 AM

    Jeff Moden - Wednesday, April 5, 2017 4:54 PM

    I'm thinking that your plan of using MachineID+F1+Kant for the PK //snip//

    He can't - 2 of those columns are nullable.
    Which also makes a unique constraint harder to implement, but not impossible.

    Ah... my apologies.  To clarify, I was not suggesting any form of concatenation.  It was meant to be a list of columns and I should have just used a comma to separate them.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden - Thursday, April 6, 2017 5:10 PM

    gvoshol 73146 - Thursday, April 6, 2017 5:39 AM

    Jeff Moden - Wednesday, April 5, 2017 4:54 PM

    I'm thinking that your plan of using MachineID+F1+Kant for the PK //snip//

    He can't - 2 of those columns are nullable.
    Which also makes a unique constraint harder to implement, but not impossible.

    Ah... my apologies.  To clarify, I was not suggesting any form of concatenation.  It was meant to be a list of columns and I should have just used a comma to separate them.

    But nullable columns are not allowed in a PK, right?  Or am I misremembering something?

  • gvoshol 73146 - Friday, April 7, 2017 5:13 AM

    Jeff Moden - Thursday, April 6, 2017 5:10 PM

    gvoshol 73146 - Thursday, April 6, 2017 5:39 AM

    Jeff Moden - Wednesday, April 5, 2017 4:54 PM

    I'm thinking that your plan of using MachineID+F1+Kant for the PK //snip//

    He can't - 2 of those columns are nullable.
    Which also makes a unique constraint harder to implement, but not impossible.

    Ah... my apologies.  To clarify, I was not suggesting any form of concatenation.  It was meant to be a list of columns and I should have just used a comma to separate them.

    But nullable columns are not allowed in a PK, right?  Or am I misremembering something?

    Correct but you don't actually need a PK.  It can be a UNIQUE clustered or non-clustered index.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply