Just a Theory

By David E. Wheeler

What Name Do You Use for an Order Column?

Quick poll.

Say that you have a join table mapping blog entries to tags, and you want the tags to be ordered for each entry. The table might look something like this:

CREATE TABLE entry_join_tag (
    entry_id integer REFERENCES entry(id)
                    ON UPDATE CASCADE
                    ON DELETE CASCADE,
    tag_id   integer REFERENCES tag(id)
                    ON UPDATE CASCADE
                    ON DELETE CASCADE,
    ord       smallint,
    PRIMARY KEY (entry_id, tag_id)
);

It’s the ord column I’m talking about here, wherein to order tags for each blog entry, you’d do a select like this:

SELECT entry_id, tag_id
  FROM   entry_join_tag
 ORDER BY entry_id, ord;

So my question is this: What name do you typically give to the ordering column, since “order” itself isn’t available in SQL (it’s a reserved word, of course). Some of the options I can think of:

  • ord
  • ordr
  • seq
  • place
  • rank
  • tag_ord
  • tag_order
  • tag_place
  • tag_rank
  • tag_seq

Leave a comment to let me know. Thanks!

Looking for the comments? Try the old layout.

More about…