1 Replies - 2510 Views - Last Post: 11 October 2012 - 09:27 PM

#1 -Nix-  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-December 11

Need help creating a table.

Posted 11 October 2012 - 09:16 PM

As you can see below, Ive kind of got some of it done. This is my classes first SQL homework assignment and im excited! Unfortunately my glory of feeling like i knew what i was doing was short lived. Each of these attributes has specifications listed below. Ive deleted the ones if already got figured out, but Ive still got a few that i need to code. Any help would be greatly appreciated, i really want to learn this and my book/teacher are not very helpful; and when it comes to Google searching i really don't know what to ask, the questions are so broad that i don't get specific answers.

Also feel free to point out any mistakes in what ive already got written, thanks!

Attribute requirements:
CRS_CREDIT - integer in range of (1, 2, 3, 4), default 4
CLASS_SECTION - a 1-digit integer in range of (0, 1, 2, 3, 4, 5, 6, 7, 8)
CLASS_ROOM - exactly 6 characters (can be NULL)
STU_NUM a 6-digit integer, PK in STUDENT, PK and FK in ENROLL
STU_HRS - integer (greater than or equal to 0 and less than 1000), default 0
STU_CLASS - exactly 2 characters in range of (Fr, So, Jr, Sr, Gr)
STU_GPA - a number with 2 decimal places from 0 to 4.00, default 0
ENROLL_GRADE - exactly 1 character in range of (A, B, C, D, F, I, W, Z), default Z

What i have so far!
SET ECHO ON;

CREATE TABLE COURSE
(
CRS_CODE 		VARCHAR(8)	NOT NULL,
CRS_DESCRIPTION 	VARCHAR(35)	NOT NULL,
CRS_CREDIT 		
PRIMARY KEY (CRS_CODE),        
)
;

CREATE TABLE XCLASS
(
CLASS_CODE		NUMBER(5)	NOT NULL,				
CLASS_SECTION		
CLASS_TIME		VARCHAR(25)	NOT NULL,
CLASS_ROOM
PRIMARY KEY (CLASS_CODE),
FOREIGN KEY (CRS_CODE) REFERENCES XCOURSE(CRS_CODE)
)
;

CREATE TABLE ENROLL
(
CLASS_CODE
STU_NUM
ENROLL_GRADE
PRIMARY KEY (CLASS_CODE, STU_NUM)
)
;

CREATE TABLE STUDENT
(
STU_NUM			NUMBER(6)	NOT NULL,
STU_LNAME		VARCHAR(25)	NOT NULL,
STU_FNAME		VARCHAR(20)	NOT NULL,
STU_INIT		CHAR(1),
STU_DOB			DATE		NOT NULL,
STU_HRS					DEFAILT'0'
STU_CLASS		
STU_GPA			NUMBER(4,2)	DEFAULT'0'
STU_PHONE		NUMBER(4)	NOT NULL,
PRIMARY KEY (STU_NUM)
)
;



Is This A Good Question/Topic? 0
  • +

Replies To: Need help creating a table.

#2 -Nix-  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-December 11

Re: Need help creating a table.

Posted 11 October 2012 - 09:27 PM

For ENROLL_GRADE would this be right?


ENROLL_GRADE CHAR(1  NOT NULL  CHECK(ENROLL_GRADE IN ('A', 'B', 'C', 'D', 'F', 'I', 'W', 'Z')),



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1