Write a CHECK constraint that expresses the following condit

Write a CHECK constraint that expresses the following condition on attribute Rating in table Movies in Movie Database: “Any possible value of Rating is either a null value or a number in the interval from 0 to 10 inclusively”.

Write a CHECK constraint that expresses the following condition on records in table Laptop in Hardware Database: “If the screen is larger than 20, then the price is higher than 2000”.

Solution

ALTER TABLE Movie.Movies ADD CHECK ((Rating >= 0 AND Rating <= 10) OR Rating IS NULL); checks whether the Rating attribute is within the range 0 - 10, or null.

ALTER TABLE Hardware.Laptop ADD CHECK(CASE WHEN screen > 20 THEN price > 2000 END); checks whether the price is higher than 2000, for screen larger than 20.

Write a CHECK constraint that expresses the following condition on attribute Rating in table Movies in Movie Database: “Any possible value of Rating is either a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site