3 ms·
A primary key is really just the combination of the unique and not-null constraints. My preferred way of handling this is to have a surrogate key as the primary
by damien 20y ago
A primary key is really just the combination of the unique and not-null constraints. My preferred way of handling this is to have a surrogate key as the primary key (for performance and general ease-of-use), but also apply multi-column unique constraints on the natural key to enforce data integrity. The main place where I don't use a surrogate key is for many-to-many join tables (which I think is the common practice).