1

I have this table:

CREATE  TABLE `sold` (
`part_ID` INT(11) NOT NULL ,
`date` DATE NOT NULL ,
 PRIMARY KEY (`part_ID`, `date`) ,
 FOREIGN KEY (`part_ID` )
 REFERENCES `part` (`part_ID` );

This table represent parts sold each day, constraint says number of sales should be at least 25 and at most 100. How can I implement this constraint?

I think it should start with something like this:

CHECK ( NOT EXISTS ...
2
  • @AshReva enforcing this constraint: number of sales should be at least 25 and at most 100. Commented Mar 11, 2013 at 19:04
  • Please don't cross-post: dba.stackexchange.com/q/36413/1822 Commented Mar 11, 2013 at 22:24

1 Answer 1

1

try below

CONSTRAINT chk_sales CHECK (columnName>=25 AND columnName <=100)

Also refer this link

Sign up to request clarification or add additional context in comments.

10 Comments

There is no column that holds number of sale!!
Then cant you have it? How will you add constraint then?
If i knew it, I wouldn't ask!
then can you add column as i said?
No. Table can not be altered.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.