devxlogo

Many Primary Keys for a Single Table

Many Primary Keys for a Single Table

Have you ever wanted to have 1:1 relation between tables (i.e. a table in which two columns act like primary key not combined but separately)?
DB only supports a single column, or group of columns, as primary key. How do you get primary key behavior for 2 columns in DB?
Define one column a primary key and the other columns with Unique+NotNull constraint. This gives the columns all the features of Primary Key.
Note: This also works in SQL Server, Oracle, and MSAccess.

devx-admin

Share the Post: