Primary Key versus Unique Constraint?

前端 未结 16 1920
轮回少年
轮回少年 2020-12-13 03:49

I\'m currently designing a brand new database. In school, we always learned to put a primary key in each table.

I read a lot of articles/discussions/newsgroups posts

16条回答
  •  眼角桃花
    2020-12-13 04:29

    Can you provide references to these articles?

    I see no reason to change the tried and true methods. After all, Primary Keys are a fundamental design feature of relational databases.

    Using UNIQUE to serve the same purpose sounds really hackish to me. What is their rationale?

    Edit: My attention just got drawn back to this old answer. Perhaps the discussion that you read regarding PK vs. UNIQUE dealt with people making something a PK for the sole purpose of enforcing uniqueness on it. The answer to this is, If it IS a key, then make it key, otherwise make it UNIQUE.

提交回复
热议问题