devxlogo

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.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Seasoned Architects Evaluate New Tech

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.