Business Key vs. Primary Key

One concept that I believe needs to be incorporated into openbiz is the concept of a "business key".

A business key is a field or set of fields that uniquely identifies a record from a business or logical perspective. Sometimes the business key and the primary key are one and the same. But often they are not, and often the primary key (as in the case of a serial column) is useless to an end user.

Consider the following case - a multi-organization order table:

Table: ord

Columns:
ord_id serial
org_code char(2)
order_num integer

Here ord_id is the primary key.. a serial column.
org_code is a foreign key to an "org"anization table
order_num is unique per organization (controlled via application code thru an org_ord_num table)

The Business key here is (org_code, order_num)

Ord_id - is of no relevance to the end user - and shouldn't even be displayed anywhere.

NOTE: A second primary (alternate) key is not the same as specifically identifying a business key.. identifying a business key could drive application logic better.

One use could be to automatically visually segregate the business key in the user interface, and make these unalterable on modify.

It may even make sense to provide for Candidate keys - so that openbiz can enforce uniqueness across all keys, but only have 1 primary key and 1 business key.

Unique keys (business keys)

Unique keys (business keys) were discussed before and still on our todo list.

Andrew