Another option is to have a validation table for the status column called VAL_GAME_STATUS. GAMES.STATUS will be the foreign key for VAL_GAME_STATUS, and VAL_GAME_STATUS migt looks like
CREATE TABLE VAL_GAME_STATUS -- Oracle format - modify as needed for other DB (STATUS NUMBER PRIMARY KEY, DESCRIPTION VARCHAR2(50) NOT NULL UNIQUE, SORT_ORDER NUMBER NOT NULL UNIQUE);
Given this, a request to get sorted results from GAMES becomes
SELECT g.* FROM GAMES g INNER JOIN VAL_GAME_STATUS s USING (STATUS) ORDER BY s.SORT_ORDER;
The downside here is that you need to make a connection to sort the data, but this is a minor hit, since VAL_GAME_STATUS is a small table that can probably be stored in memory. The advantage is that you can change the sort order on the fly without touching your code. It is also easy to add new status values ββwith the appropriate sort order.
Share and enjoy.
Bob jarvis
source share