r/SQL • u/Key-Bit-3552 • Jun 30 '26
Discussion Is using 3-letter status codes outdated?
I had a pretty big debate at work over how status values should be stored in lookup tables.
For example, imagine an OrderStatus table with three columns:
ID
Status
Description
My preference is:
1 | DRAFT | Draft
2 | SUBMITTED | Submitted
3 | INCOMPLETE | Incomplete
Some people on my team prefer:
1 | DRT | Draft
2 | SUB | Submitted
3 | INC | Incomplete
My reasoning is:
Storage isn’t really a concern for values this small anymore.
Full words are much easier to read in SQL queries, logs, APIs, and code.
They make code more self-documenting.
Modern IDEs and AI tools also tend to work better with descriptive values.
For example:
SELECT *
FROM Orders
WHERE Status = 'INCOMPLETE';
vs.
SELECT *
FROM Orders
WHERE Status = 'INC';
To me, the first query is immediately understandable without needing to remember what each abbreviation means.
I’m curious what other developers think. Are abbreviated status codes still considered best practice, or are full descriptive values more common nowadays?
Edit: the example query is pseudocode. Yes I would normally store the status ID in the orders table. The example query is for brevity
7
u/Yavuz_Selim Jun 30 '26
It doesn't make any sense to use a lookup table in your case if you're not going to store the ID...
What is the benefit of storing the same value multiple times? Once in the Orders table, and twice in the lookup table - what is even the benefit of that lookup table?
183
u/ComicOzzy sqlHippo Jun 30 '26
There is no reason at all to make that code something cryptic and arbitrarily limited to 3 characters.
127
u/Blecki Jun 30 '26
Ban all abrv.
31
u/Cruxwright Jun 30 '26
You are describing a concept from days of slow storage. Whatever data you were going to operate on was loaded to a buffer. Short code values were common because you could pack more into the buffer.
That said, if you picked up this concept from your job, and they're running an inhouse legacy app, you may have some of these old concepts lurking in the plumbing of the app. There could be other quirks like no columns names over 8 characters. Check with your team before you get too far along in your design.
25
u/Straight_Waltz_9530 Jun 30 '26
Enums. Best of all worlds: readable, storage efficient, and allow only valid values.
6
u/Rohml Jun 30 '26 edited Jun 30 '26
The limit of shorter character is more for readability on a page rather than a way to limit storage usage nowadays. When viewing in a report or small mobile device, the shorter length allows you to put more fields in view of the user but still allows them the same level of comprehension, that is why shorter fields often uses unique letters so its quickly and easily readable.
6
u/NW1969 Jun 30 '26
Having 3 letter codes makes little sense these days but having short and long descriptions may do.
Having the same word in upper and lower case, as in your example, seems redundant, IMO.
Having something like this may make more sense, if the long description adds value:
1 | DRAFT | A work-in-progress version that is still editable and has not been finalized
2 | SUBMITTED | The finalized document has been officially sent to a reviewer, recipient, or system for approval
3 | INCOMPLETE | Required fields or pages are missing, preventing the document from being processed
1
u/nacnud_uk Jun 30 '26
SELECT *
FROM Orders
WHERE Status = 'INCOMPLETE'
No no no no no no.
Status has to be a number, surely?
9
u/garster25 Jun 30 '26
The one thing I see about the 3-digit code is they are all the same length so a text listing of this and they line up. Similar to zero-padding numbers in dates.
Since you have the full name of the status then the UPPERCASE version is a bit redundant. So thinking about this I like the one that is NOT your preference.
Man, it does kinda suck working on a team. If I work with only one other person my Boss picks a "lead" and as far as I am concerned that person gets 51% of the vote.
10
u/grumpy_munchken Jun 30 '26
Creat a status dim table. Then you can have StatusID, StatusCode and StatusDescription
6
u/FastlyFast Jun 30 '26
You have the table StatusOrders, but you still store the full value in Orders? This conversation is completely redundant if you use a dimension.
Select .. from orders o Join StatusOrders so ... Where o.StatusOrdersID=2 (so.status='Incomplete")
You always store the full value in the StatusOrders table. Having the StatusOrder column in the Orders completely negates the purpose of the Dimension.
3
u/Consistent_Cat7541 Jun 30 '26
It depends on the solution. If the solution interoperates with other solutions, especially DBF solutions, then the field length is actually important. (i.e, DBF records cannot be longer than 4000 characters total). Your environment may be a mix of older and newer databases. If you have a rule set in place, restricting certain values to 3 characters, it's likely for a good reason.
For a completely new solution, I agree that longer words are better.
2
u/Animalmagic81 Jun 30 '26
It feels like having an abbreviation is just another lookup on top of the identity column. To get the full description you still need to do a lookup on the table which seems a waste of time.
2
u/lmarcantonio Jun 30 '26 edited Jun 30 '26
Why not an enum (if your db supports it)? it get down to a short integer (one or two bytes on table)
EDIT: storage (maybe) would not an issue but you would fill more page cache and the comparison would be more expensive. It all depends if this table is on the order of 1k records or, say, 100M records.
2
u/Outrageous_Let5743 Jun 30 '26
Its is not the 80s anymore where abbreviations are needed
2
u/Aggressive_Ad_5454 Jun 30 '26
If you do use three letter codes, be sure to declare the columns containing them as ASCII, iso8859-1, or some other one-byte-per-character encoding. If you use an encoding like utf-8, the WHERE col = ‘ABC’ filtering will be less efficient and you may as well have gone with the variable length codes.
2
u/GreyHairedDWGuy Jul 01 '26
You can do both. Have a short code column and long code column and description. Will keep them happy :)
Storage is cheap. If you can only have 1, use the longer version.
3
u/BigMikeInAustin Jun 30 '26
Call up your colleagues every hour to ask what DRT stands for because you forgotagain.
And always pronounce it as some other word when mentioning any code. Such as "what happens when we have an order in dirt status?" Or "should this order be minus /subtract / substitute status? Oh I never remember what these abbreviations stand for."
3
u/kremlingrasso Jun 30 '26
Whoever recommended this is an eejit.
1
u/aatkbd_GAD Jun 30 '26
For me, it is still dependent on use case. What type of analytics are you doing on the data? Numerical order status might be easier to chart or complete gap analysis on over 3 character codes with no logically order. Do your terminals feeding transactions have any bandwidth issues that shorter codes could increase reliability. Are data integrity checks faster shorter strings than longer.
Storage is only one contraint. Memory, bandwidth and compute still need to be considered to. Memory/cache is expensive right now. AI compute might be faster with shorter values dependent on use case. Status values will get vectoried in many cases. Don't assume that AI will treat "open transaction" verses opn any different after training. You might save a few tokens on shorter terms after a little training.
1
u/asisoid Jun 30 '26
Wouldn't you have a StatusOrders table then select the StatusOrders.ID from Orders?
1
u/GuyWithLag Jun 30 '26
Just tell them "longer identifiers help with Agentic AI understand the rows better".
1
u/feignapathy Jun 30 '26
Meanwhile I'm over here just using d/s/i
lol
1
u/Zestyclose-Turn-3576 Jun 30 '26
A simple status like that might not be need a lookup table in a framework like Rails, where it could be implemented as an enum (integer column where the meaning is held in the app) so the code would be: `Order.incomplete`. Or you'd change an order instance's status with `@order.complete!`.
So the application framework you're using might be very significant to the design here.
1
u/de6u99er Jun 30 '26
Postgres and MySql support enums. The other option are Check Constraints which is a SQL 92 standard.
You're all welcome!
1
u/Famous_Substance_ Jun 30 '26
Yes absolutely, I don’t see any reasons on doing that. I’ve tested Databricks Genie on tables with these kind of naming conventions and the results where terrible, it’s impossible for an AI to reason on this.
1
u/MoonBatsRule Jun 30 '26
Why would you use the numeric ID in the OrderStatus table? What purpose does it serve? Not for a foreign key, since you are suggesting using Status.
1
u/PurifyHD Jul 01 '26
Full stats, all the time. Abbreviations are pointless and slow down the reader. Make it clear and unambiguous. If it's a UI problem, that's a UI person's problem to map "DRAFT" to "DFT" or something like that.
1
u/fizzy_lychee Jul 04 '26
Always better to be more descriptive and clear. Having things written out shorter is honestly a practice that was a result of limited storage space. We generally don't have that limitation, or at the very least, not to the extent of being worried about using short hand to save space
1
u/PickledDildosSourSex Jul 04 '26
IMO TBD but YSK SQL JTM
1
u/Ok-Can-2775 Jul 06 '26
Doesn’t sound like anyone (mostly) here has to look at the reports they write. Space is limited on screens and paper if you need to print. Readability is definitely a thing. Some users like full descriptions and some don’t.
An ERP I worked on called JDE had a generic code file (F0004) that contained codes and two descriptions, which were automatically available in their toolset.
Also using descriptions becomes challenging when you’re using that data to get to other things like alternate (language) descriptions which are typically kept in a different table.
1
u/zesteee Jun 30 '26
The only reason I’d want to use three letter codes is if I knew I’d be writing a lot of code with those same codes. Not something that can’t be overcome in other ways, just a small convenience.
1
u/trebor_indy Jun 30 '26
Store the code and description in a lookup table; always do selections based on the code, but this allows rewording of the description, such as a change from CLOSED to COMPLETE etc. when original word was not the best (ensure MEANING did not change though).
0
u/somewhatdim Jun 30 '26
storage *can* be a concern. how big is the DB? How many indexes do you build over those columns? Often things are more complicated than "they be dumb" -- not always, but often enough that you're better off thinking a bit before deciding.
0
u/RonJohnJr Jun 30 '26
Your team members are right, but three characters is a bit too short and inflexible. I found that four characters is expressive while still minimizing typing and keeping things columnar (which is useful in my line of work).
And don't forget to put a unique key on the abbreviation column.