Solved Difficulty sorting an alphanumerical text field

I have resolved this issue by adding a sort field. This field contains a higher number (5) where there are no leading zeros, a smaller number (4) where there is one leading zero, a smaller number (3) if there are two leading zeros etc.

There is no need for that. Arnelgp's solution caters for any number of leading zeros. More importantly, adding the extra column means that the table is no longer normalized to Boyce Codd Normal Form (BCNF) as the new column is functionally determined by the registration number, which is not a candidate key. The formal definition of BCNF is:

A relvar is in BCNF if and only if every nontrivial, left-irreducible functional dependency has a candidate key as its determinant.

Informally this requires that every non-key column's only determinants must be candidate keys. The lack of normalization to BCNF leaves the table open to the risk of update anomalies.
 

Users who are viewing this thread

Back
Top Bottom