Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7013815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:26:24+00:00 2026-05-27T22:26:24+00:00

Q: Is there any way to implement self-documenting enumerations in standard SQL? EXAMPLE: Column:

  • 0

Q: Is there any way to implement self-documenting enumerations in “standard SQL”?

   EXAMPLE:
   Column: PlayMode
   Legal values: 0=Quiet, 1=League Practice, 2=League Play, 3=Open Play, 4=Cross Play

What I’ve always done is just define the field as “char(1)” or “int”, and define the mnemonic (“league practice”) as a comment in the code.

Any BETTER suggestions?

I’d definitely prefer using standard SQL, so database type (mySql, MSSQL, Oracle, etc) should’t matter. I’d also prefer using any application language (C, C#, Java, etc), so programming language shouldn’t matter, either.

Thank you VERY much in advance!

PS:
It’s my understanding that using a second table – to map a code to a description, for example “table playmodes (char(1) id, varchar(10) name)” – is very expensive. Is this necessarily correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:26:25+00:00Added an answer on May 27, 2026 at 10:26 pm

    The normal way is to use a static lookup table, sometimes called a “domain table” (because its purpose is to restrict the domain of a column variable.)

    It’s up to you to keep the underlying values of any enums or the like in sync with the values in the database (you might write a code generator to generates the enum from the domain table that gets invoked when the something in the domain table gets changed.)

    Here’s an example:

    --
    -- the domain table
    --
    create table dbo.play_mode
    (
      id          int         not null primary key clustered ,
      description varchar(32) not null unique nonclustered   ,
    )
    
    insert dbo.play_mode values ( 0 , "Quiet"          )
    insert dbo.play_mode values ( 1 , "LeaguePractice" )
    insert dbo.play_mode values ( 2 , "LeaguePlay"     )
    insert dbo.play_mode values ( 3 , "OpenPlay"       )
    insert dbo.play_mode values ( 4 , "CrossPlay"      )
    
    --
    -- A table referencing the domain table. The column playmode_id is constrained to
    -- on of the values contained in the domain table playmode.
    --
    create table dbo.game
    (
      id          int not null primary key clustered ,
      team1_id    int not null foreign key references dbo.team(      id ) ,
      team2_id    int not null foreign key references dbo.team(      id ) ,
      playmode_id int not null foreign key references dbo.play_mode( id ) ,
    )
    go
    

    Some people for reasons of “economy” might suggest using a single catch-all table for all such code, but in my experience, that ultimately leads to confusion. Best practice is a single small table for each set of discrete values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to implement a URL mechanisim in asp.net like it has
is there any way to implement timeout option for individual tests in a bunch
Is there any way to implement pop-ups similar to the system ones on iPhone?
Is there any way to implement something similar to Chatroulette without using Flash or
Is there any tricky way to implement a set data structure (a collection of
Is there any other way in java to implement call backs apart from inner
Is there any non-hacky way to determine wether a class' superclass implements a particular
Is there any way to check whether a file is locked without using a
Is there any way to capture the MouseDown even from the .NET 2.0 TextBox
Is there anyway to use a bounded wildcard require a class implement more than

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.