Simple Database normalization question...

Posted by user365531 on Stack Overflow See other posts from Stack Overflow or by user365531
Published on 2010-06-13T05:12:52Z Indexed on 2010/06/13 5:22 UTC
Read the original article Hit count: 264

Filed under:
|
|
|

Hi all,

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

© Stack Overflow or respective owner

Related posts about sql

Related posts about database