Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136

    design of datatype or object type

    Hi All,

    i try to display the following structure:

    table X:
    =======
    ID,
    ....,
    CATEGORY

    , whereby:


    CATEGORY = NULL | WORD1 | WORD2| [ACEF]


    Now is my question, what is the best solution:
    1) to create a table for category, a table for [ACEF] with CHECK CONSTRAINT

    or

    2) to create a type for ACEF

    or

    3) to create just a CHECK CONSTRAINT for CATEGORY

    or

    4) ?


    Thanks in advance!
    Regards,
    Julia

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136
    Solved:

    PHP Code:

    create table x   
    (id, ..., category); 
    create table cat (category); 

    ALTER TABLE cat ADD 
    CONSTRAINT PK_cat PRIMARY KEY (category)); 


    ALTER TABLE X ADD 
    CONSTRAINT FK_X_cat FOREIGN KEY (category
    REFERENCES cat(category)); 

    ALTER TABLE cat ADD 
    CONSTRAINT CH_cat 
    CHECK 
    (INSTR(TRANSLATE(category,'ACEFX','XXXXU'),'X') > 
    OR category in ('WORD1''WORD2'
    )); 
    Regards,
    Julia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •