1. Values for the staffid attribute should be a string of exactly 4 characters, and should start with
letter ‘s’.2. Values for the sid attribute of the Student relation should be a string of exactly 4 characters, and
should start with letter ‘u’.3. Values for the title attribute should be one of the following strings: “Lecturer”, “Senior
Lecturer”, “Associate Professor” and “Professor”.4. Values for the credits attribute should be integers between 0 and 6.5. Values for the sex attribute should be either ‘M’ (for male) or ‘F’ (for female). NULL values are not
allowed.
letter ‘s’.2. Values for the sid attribute of the Student relation should be a string of exactly 4 characters, and
should start with letter ‘u’.3. Values for the title attribute should be one of the following strings: “Lecturer”, “Senior
Lecturer”, “Associate Professor” and “Professor”.4. Values for the credits attribute should be integers between 0 and 6.5. Values for the sex attribute should be either ‘M’ (for male) or ‘F’ (for female). NULL values are not
allowed.
letter ‘s’.in other database, you can use the CHECK to enforce the data comply with the rule, but MySQL does not support CHECK ! in MySQL it can be done in the Trigger
2. Values for the sid attribute of the Student relation should be a string of exactly 4 characters, and
should start with letter ‘u’.same like Question 1
3. Values for the title attribute should be one of the following strings: “Lecturer”, “Senior
Lecturer”, “Associate Professor” and “Professor”.in MySQL, you can use the ENUM , for example
CREATE TABLE sizes (
name ENUM('small', 'medium', 'large')
);
4. Values for the credits attribute should be integers between 0 and 6.same like Question 1
5. Values for the sex attribute should be either ‘M’ (for male) or ‘F’ (for female). NULL values are not
allowed.same like question 3
CREATE TABLE sizes (
sex ENUM('small', 'medium', 'large') not null
);
add constraint CK_Student check (sex IN(‘M','F'))
PostgreSQL 8.1 中文文档