Change my pc in the table

If I have a table with a name university, with two fields, one for id_university, that is PK and the other for name_of_university. Each university name is unique and cannot be repeated.

In this case, I can delete id_universityand put the key name_of_universityas Primary, right?

Something like that:

Table

university
-----------------------
pk name_of_university

thank

+3
source share
4 answers

You can do it, but you shouldn't. The name of the university is a business key, and as such may change. One of the criteria for identifying a candidate’s primary keys is that they must be invariant.

, () .. -. , , . , .

 alter table university
      add constraint uni_name_uk unique (name_of_university);
+4

id_university name_of_university.

+2

, .

.
PK , .

InnoDB PK , .
, , .
. : -

( ), .

0
source

Yes, it's right. The key is the key. If you have more than one key, then it does not matter which key you call the primary. What matters is how you intend to implement and use them.

0
source

All Articles