When will you need to change the primary key value?

I read on foreign keys, and for postgres, and noticed that it allows cascading updates for foreign keys.

Well, my question is: when do you need to update the row primary key?

Apparently this guy needs http://www.oreillynet.com/onlamp/blog/2004/10/hey_sql_fans_check_out_foreign.html , but I don't quite understand how this could ever be useful.

Edit: I see for natural primary keys how this can be used. But what about technical primary keys? Units that don't matter and are almost always automatically generated when pasted?

+3
source share
7

... , . , .

PK , - , .

+2

, , , SSN .

: .

+1

, . , ( - - ).

.

+1

, , ( ) PK. PK , ( ). . . .

, , .

, , - . , .

+1

, .

: , . 1 2010 .

, ( ) . , . .

+1

, ( ), - , . , , , .

+1

You may need to do this if you are using a natural primary key (one that has actual value in the problem area). If the value has changed, you will need to cascade the change.

I suggested that a bad example of this would be a database of buildings on the school campus, with the name of the building being the primary key (don't do this at home). If the building is renamed to bribe the honor of a new donor, then the key should change.

0
source

Source: https://habr.com/ru/post/1733285/


All Articles