Accenture Interview Questions | Primary Key

Question

Can we have another column in a table other than a primary key column which will act as a primary key?

in progress 0
TheDataMonk 4 years 5 Answers 1250 views Grand Master 0

Answers ( 5 )

  1. Foreign key without nulls.Also, having one to one relationship with another table

  2. A table can contain one and only one primary key.

  3. A table can only have one primary key. It is a unique identifier. example employee id, license number, etc


    Attachment
  4. 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

  5. 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.

Leave an answer

Browse
Browse