blurtanalysis email blurtid topicid confidence sentiment pri
blurt_analysis (email, blurtid, topicid, confidence, sentiment) primary key(email, blurtid, topicid) foreign key(email, blurtid) references blurt(email, blurtid) foreign key(topicid) references topic(id) constraint confidence greaterthanorequalto 0 and confidence lessthanorequalto10 constraint sentiment greaterthanorequalto -5 and sentiment lessthanorequalto 5
Solution
Create Table blurt-analysis
(email varchar(30) NOT NULL,
blurtid varchar(10) NOT NULL,
topicid varchar(10) NOT NULL,
confidence int,
sentiment int,
PRIMARY KEY (email,blurtid,topicid),
FOREIGN KEY(email,blurtid) references blurt(email,blurtid),
FOREIGN KEY(topicid) references topic(id),
CHECK((confidence >= 0) AND (confidence <= 10)),
CHECK((sentiment >= -5) AND (sentiment <= 5)));
CHECK constraint is used to check the values inserted into the table for conditions. Here the values for confidence and sentiment columns are checked for range with CHECK constraint.
