• UMG Developer (9/24/2010)


    sknox (9/24/2010)


    So that gives us 2 identifier columns, remarkably similar to the two in this QotD -- and that's where you may have a point. But I'd caution here as well. First, we need to know why that surrogate UID is there.

    No, this QotD only has one identifier:

    OrderRefNo UNIQUEIDENTIFIER NOT NULL CONSTRAINT DF_OrderRefNo DEFAULT NEWID() CONSTRAINT PK_Order PRIMARY KEY CLUSTERED,

    The other column, OrderNo, wouldn't qualify as a surrogate key or identifier in my book:

    OrderNo INT NOT NULL IDENTITY(1,1),

    The reason is there is no INDEX or CONSTRAINT that prevents duplicate values. Essentially is it just an INT field with a DEFAULT that creates sequential numbers, but someone can easily add rows with duplicate values.

    I'm confused as to why you don't think a field with the IDENTITY attribute is not a surrogate key or identifier. The only reason to use the IDENTITY attribute is to create a surrogate key or identifier. It's not possible to create duplicate values either as the value automatically increments by the value in the second position of the declaration.

    Did I miss something here?

    "Beliefs" get in the way of learning.