Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

Is it possible to have more than one composite primary key

I have a table with about 30 columns of data. I did not design the table, as it is a legacy system.
This table already has a primary key which is a composite key of four columns of data.

So here are some questions. Is it possible to have another Composite key in the table? You see, I have two other columns of data, and
it would be nice if these two other columns of data were designated as a composite key. Basically the columns are related to property rentals,
and for each property their is associated a unique email address. So each property id might represent an apartement complex.
And I just need to ensure that for each property id, the same email address is not used more than once.In other words no one living in an apartement
complex can share the same email address

These are the columns I would like as a composite primary key.
Column Name : PropertyId
Column Name : EmailAddress

Something to keep in mind is that I have a situation where many of the EmailAddress columns currently contain null data. Which I am sure
would not be acceptable for a composite primary key.

Can an expert or two give me some feedback on my question. As I don't know how to approach this.
SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brgdotnet

ASKER

I don't think that would work though if some of the email addresses are null. Because that would violoate the unique key constraint. For example if you have a property id called mulberry and there are 50 apartements with that same property id. And half of those email addressess are null, then that would violate the unique key constraint.

Because the Property Id would be repeated many times.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you