Accenture Interview Questions | Primary Key
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answers ( 5 )
Foreign key without nulls.Also, having one to one relationship with another table
A table can contain one and only one primary key.
A table can only have one primary key. It is a unique identifier. example employee id, license number, etc
Attachment
There can be multiple columns which can act as a primary key due to distinct values in the column. It can be used as primary key to join the other table; hence it is potential candidate for primary key hence referred as foreign key. But ideally,for a table there should be one primary key
The short answer is no, a table is not allowed to contain multiple primary keys, as that goes against the fundamental principles of relational database design (see: [database normalisation](https://en.wikipedia.org/wiki/Database_normalisation) and [Third normal form](https://en.wikipedia.org/wiki/Third_normal_form)).
It is possible for a table to have multiple candidate keys, which effectively behave similar to a primary key in that a candidate key is unique, NOT NULL, and is a singular representation of that table record.
However, when it comes to selecting which one attribute will be assigned as the primary key for the table, the choice comes from the list of all potential candidate keys (hence the name, they are candidates for becoming a primary key). Ultimately, only one candidate key is selected as the best representative attribute for that record, to be used in this table as the primary key and referenced elsewhere in the database by other tables via their respective foreign keys.