GSD Questions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
701 B

7 years ago
  1. CREATE TABLE STUDENT (
  2. STUDENT_ID INT PRIMARY KEY,
  3. LASTNAME VARCHAR(40) NOT NULL,
  4. FIRSTNAME VARCHAR(40) NOT NULL,
  5. GENDER VARCHAR(1) NOT NULL,
  6. CONSTRAINT CHK_STUDENT_ID
  7. CHECK (STUDENT_ID>=100000 AND STUDENT_ID<=999999),
  8. CONSTRAINT CHK_GENDER
  9. CHECK (GENDER='m' OR GENDER='f')
  10. );
  11. CREATE TABLE EXAM (
  12. STUDENT_ID INT,
  13. COURSE VARCHAR(40),
  14. GRADE DECIMAL(2,1),
  15. ATTEMPT INT,
  16. CONSTRAINT PK PRIMARY KEY(STUDENT_ID, ATTEMPT, COURSE),
  17. CONSTRAINT CHK_ATTEMPT CHECK (ATTEMPT IN (1,2,3)),
  18. CONSTRAINT CHK_GRADE CHECK (
  19. GRADE IN (1.0,1.3,1.7,2.0,2.3,2.7,3.0,3.3,3.7,4.0,5.0)
  20. ),
  21. CONSTRAINT FK_STUDENT_ID FOREIGN KEY (STUDENT_ID)
  22. REFERENCES STUDENT(STUDENT_ID) ON DELETE CASCADE
  23. );