Not the answer you need?
Register and ask your own question!

PRIMARY KEY or FOREIGN KEY?

takeda14121990takeda14121990 EntrantLegacy User Role Beginner
Say I have a users table with uid, name, email, and password with a PRIMARY KEY on uid and a UNIQUE KEY on email.

Now I want to create a profiles table with uid, and other extended profile information. Should uid be a PRIMARY KEY or a FOREIGN KEY referencing uid from users in this case?

Comments

  • mirfanmirfan Database Administrator Inactive User Role Beginner
    Profile table UID column should be foreign key referencing UID from users table.
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.