Constraints HELP ME!

  • Hello!

    Word of the DAY is... Integration Services  ROCK!

    I have got a unwell rounded ( that being I ) quesion.

    I have an address table and i also have an OrderAddress table i am combining these into one but i can not find out how to add the constraints that i need...

    Here is what i have -- ([AddressType] = 'S' or [AddressType] = 'B') -- Here is what i need...

    ([AddressType] = 'S' or [AddressType] = 'B' or [AddressType] = 'H' or [AddressType] = 'W')

     

    What to do?

     

     

    Dam again!

  • Why not drop and recreate the constraint?

  • Because i did not know how to do that untill yesterday.

    AKA --- alter table orderaddress add CONSTRAINT CK_AddressType CHECK ([AddressType] in ('S', 'B', 'W', H')) ---

    However, this has lead me to realize that this is not a good design. I need some help with an idea of how to do this.

    I am trying to restructure my database model to something more workable. As you can see in the screenshot --   http://www.ConstructionSuperCenter.Com/Help/sql-addressHelp.jpg -- that my Users are all bunched up with their information, and i really want to seperate all of this. Would i be doing the right thing to move the addresses into ONE table and i want to move the CompanyPhotos to another table also in case the photo data gets out of hand.

    I would like a professionals opinion's or design idea's on this please

    thanks!

    Erik

    Dam again!

  • I cannot read the referenced JPG, but you could make an AddressType table, which could map your address type to an address type name, and then add the address types that you already have, and then make a foreign key constraint to constrain that the user table address type field must exist in the AddressType table.

  • That is a good idea. i have the UserType table like that...

    One thing that i would like to ask is what do i do if the user has the same billing address as the shipping address?

    Dam again!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply