If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > design of datatype or object type

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-15-04, 08:50
julla27 julla27 is offline
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old 04-15-04, 10:55
julla27 julla27 is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On