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

  • Home
  • SEARCH
  • 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 865233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:36:33+00:00 2026-05-15T09:36:33+00:00

I have a quick question regarding a database that I am designing and making

  • 0

I have a quick question regarding a database that I am designing and making sure it is normalized…

I have a customer table, with a primary key of customerId. It has a StatusCode column that has a code which reflects the customers account status ie. 1 = Open, 2 = Closed, 3 = Suspended etc…

Now I would like to have another field in the customer table that flags whether the account is allowed to be suspended or not… certain customers will be automatically suspended if they break there trading terms… others not… so the relevant table fields will be as so:

Customers (CustomerId(PK):StatusCode:IsSuspensionAllowed)

Now both fields are dependent on the primary key as you can not determine the status or whether suspensions are allowed on a particular customer unless you know the specific customer, except of course when the IsSuspensionAllowed field is set to YES, the the customer should never have a StatusCode of 3 (Suspended).

It seems from the above table design it is possible for this to happen unless a check contraint is added to my table. I can’t see how another table could be added to the relational design to enforce this though as it’s only in the case where IsSuspensionAllowed is set to YES and StatusCode is set to 3 when the two have a dependence on each other.

So after my long winded explanation my question is this: Is this a normalization problem and I’m not seeing a relational design that will enforce this… or is it actually just a business rule that should be enforced with a check contraint and the table is in fact still normalized.

Cheers,

Steve

  • 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-15T09:36:33+00:00Added an answer on May 15, 2026 at 9:36 am

    Yes it is possible. You can do it with a check constraint and a Case statement:

    Create Table Customer   (
            CustomerId <datatype> not null Primary Key
            , StatusCode int not null
            , IsSuspensionAllowed int not null Default( 1 )
            , Constraint CK_Customer_IsSuspensionAllowed 
                        Check ( IsSuspensionAllowed In(0,1) )
            , Constraint CK_Customer_StatusCodeRange 
                        Check ( StatusCode Between 0 And ?? )
            , Constraint CK_Customer_StausCodeValid 
                        Check ( Case
                    When StatusCode = 3 And IsSuspensionAllowed = 1 Then 0
                                                                    Else 1
                                                                    End = 1 )
            , ....
            )
    

    You did not mention the data type of the PK so I simply inserted a placeholder. If you are using SQL Server, you can use a bit column in lieu of the int and check constraint I mentioned above (bit is not part of the ANSI spec).

    This is a good example of where surrogate keys for things like status codes do not always work out well. It would be better to have string values represent the status codes in which case the Case statement would read When StatusCode = 'Suspended' And IsSuspendedAllowed = 0....

    From a normalization standpoint, I do not see anything wrong. Whether suspension is allowed is an attribute specific to a Customer and not another attribute. What you are saying with the check constraint, that certain states of attribute values cannot exist which is fine.

    Btw, wouldn’t make more sense to say that the Status of “Suspended” is not allowed when IsSuspensionAllowed = 0? Using your data, shouldn’t the state that is not allowed be StatusCode = 3 and IsSuspensionAllowed = 0?

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

Sidebar

Related Questions

I have a quick question regarding memory management that I am not quite sure
I had a quick question regarding RegEx... I have a string that looks something
Just a quick question to clear up some confusion that I have regarding units
I have a quick question regarding debug and release in VS 2008. I have
Hi I have a quick question regarding json responses from the web services, I
I am somewhat new to LINQ and have a quick question regarding deleting. Say,
Good afternoon, I have a quick 'top level' question regarding the usage of Facebook
I have quick question for you SQL gurus. I have existing tables without primary
I have a quick question that I can't seem to find online. I am
I have a quick question regarding the creation of absolute URLs within a symfony

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.