By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,982 Members | 1,738 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,982 IT Pros & Developers. It's quick & easy.

modify sql code

P: 10
How can I change the below oracle sql code so that: The current enrollment of an offering must be less than the maximum enrollment.


Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE COURSES
  2.   (COURSE VARCHAR(6),
  3.    DESCRIPTION VARCHAR(60),
  4.    CREDITS INT,
  5.    CONSTRAINT pk PRIMARY KEY (COURSE));
  6.  
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE OFFERINGS
  2. ( CRN INT,
  3.   COURSE VARCHAR(6),
  4.   SECTION VARCHAR(2),
  5.   DATES VARCHAR(5),
  6.   TIMES VARCHAR(30),
  7.   INSTRUCTOR VARCHAR(30),
  8.   ROOM VARCHAR(20),
  9.   ENROLLMAX INT,
  10.   ENROLLCURRENT INT,
  11.   CONSTRAINT pk2 PRIMARY KEY (CRN),
  12.   CONSTRAINT fk1 FOREIGN KEY (COURSE) REFERENCES COURSES (COURSE));
  13.  
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE STUDENTS
  2. ( USERID VARCHAR(9),
  3.   PASSWORD VARCHAR(10),
  4.   FIRSTNAME VARCHAR(20),
  5.   LASTNAME VARCHAR(30),
  6.   PHONE VARCHAR(12),
  7.   DOB VARCHAR(40),
  8.   MAJOR VARCHAR(20),
  9.   ADDRESS VARCHAR(30),
  10.   CITY VARCHAR(30),
  11.   STATE VARCHAR(2),
  12.   ZIP VARCHAR(5),
  13.   CONSTRAINT pk3 PRIMARY KEY (USERID));
  14.  
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE ENROLLMENTS
  2. ( CRN INT,
  3.   USERID VARCHAR(9),
  4.   ENROLLDATE VARCHAR(30),
  5.   GRADE VARCHAR(2),
  6.   CONSTRAINT pk4 PRIMARY KEY(CRN, USERID),
  7.   CONSTRAINT fk2 FOREIGN KEY (CRN) REFERENCES OFFERINGS(CRN),
  8.   CONSTRAINT fk3 FOREIGN KEY (USERID) REFERENCES STUDENTS(USERID));
  9.  
Apr 1 '15 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.