I'm 开发者_StackOverflow中文版building a web app on Django. The client insists that some column on some table should be the primary key, he doesn't want autoincrement one. But also he wants that column to be modifiable in application, pointing that Postgres can deal with it (ON UPDATE CASCADE clause). How can I lead him out of it, or maybe I should agree to that? He's stubborn.
Edit: I want to know at least whether doing things as he says is harmful, or what are some gotchas in this approach.
It can be done, from Django's docs regarding auto pk:
If you'd like to specify a custom primary key, just specify primary_key=True on one of your fields. If Django sees you've explicitly set Field.primary_key, it won't add the automatic id column.
However, pk's are usually used for object identity and retrieval. Managing them manually and ensuring uniqueness is a PITA, it's not just editing them, the also need to present and unique when the object is created and stored in the db for example.
精彩评论