• Phil Factor (7/17/2014)


    @Sergei

    Please correct me if I'm wrong but I'd always believed a primary key was enforced by a constraint which was implemented by means of both a UNIQUE index and NOT NULL constraints on all the participating columns.

    Not quite.

    But I'll write about it later in a separate post.

    The reason for my pedantry is nothing to do with metaphysics but all to do with foreign keys, and candidate keys. Hmmm. I've maybe got a few more QOTDs to do, even if I'm really just asking myself.

    If we're talking about foreign keys and candidate keys there is no diffeence between PK and UNIQUE.

    I often use UNIQUE instead of PRIMARY KEY when I need to allow NULL into a PK column.

    _____________
    Code for TallyGenerator