This seems a simple question but is it still necessary to include a primary key with identity even if my columns are only a unique code and its description?

      column1 INT NOT NULL IDENTITY, 
      column2 CHAR(4) NOT NULL,
      column3 VARCHAR(10) NULL 
      CONSTRAINT pk_id PRIMARY KEY (column1),
      CONSTRAINT uq_column2 UNIQUE (column2)

Sample values:

INSERT INTO table1 VALUES ('A', 'aaa')
INSERT INTO table1 VALUES ('B', 'bbb')

If your column2 is immutable then it can serve as primary key. Only if it was to hold long values then you could consider to create a separate primary key field to save space in the tables that have a foreign key constraint with this table.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.