sqlbusiness-logicobject-relational-model

Is it a bad idea to use a database's primary key as business object identifier?


I wonder, is it bad or good idea to use auto increment primary key as business entity identifier such as Partner Id or Account Number?

Also, what pitfalls I can face if I'll choose that approach?


Solution

  • I don't think everyone shares the same opinion, but I do think it is bad practice. Passing ID's to the user as the 'key' is bad in my opinion, for a number of reasons:

    In our products, we always use a 'natural key', next to the primary key, a key that is understood by humans.

    If there is no human understandable natural key available, for example when it is a logging table, you can revert to a artificial key.