30 likes | 191 Views
Constraints & Triggers. Active elements: executes as appropriate Database integrity: insert/delete/update # of students > 3.0 < 30% name should not have numbers or special characters We must have basic data (name, gender) about students who enroll in courses
E N D
Active elements: executes as appropriate • Database integrity: insert/delete/update • # of students > 3.0 < 30% • name should not have numbers or special characters • We must have basic data (name, gender) about students who enroll in courses • Student status is either active or inactive • Student name can never be null • If you delete a course then all enrollment records for that course should be deleted OR CID should be converted to null • The number of credits a student can take in a semester should be between 6 and 15. • An attribute of Course. Course(CID, title, avgGrade)
Create table course ( course_id char (5) primary key, title varchar(20), deptvarchar (20) references department (name) ) • Create table course ( course_id char (5) primary key, title varchar(20), deptvarchar (20), FOREIGN KEY (dept) REFERENCES department (name) on delete set null on update cascade ) Create table department ( did int primary key, namevarchar (20) unique, address varchar (40) )