I have question about primary keys and unique constraints in mysql. I’m creating a table for member credentials to a website. There are attributes for email address, username, dob, etc.
I believe that most websites allow an email address to be associated with at most one user account (not sure if this is true). So I set email as my primary key. But username must also be unique and it can not be null. I’m not sure how to represent this. Should i create a unique constraint on username and explicitly declare it as not null? I don’t believe a trigger would be appropriate for this. Is there a better solution? Thanks.
try something like this,