NOR AMIRAH BT MOHD AMINUDDINB030910199TABLE : STUDENTCREATE TABLE student(stud_id CHAR(4) NOT NULL,student_name VARCHAR2(1...
TABLE: FACULTYCREATE TABLE faculty (fac_id CHAR(3) NOT NULL,lecturer VARCHAR2(20),department VARCHAR2(10),gender VARCHAR2(...
course_title VARCHAR2 (30),CONSTRAINT course_pk PRIMARY KEY (course_id));INSERT INTO course VALUES (CSC100, INTRODUCTION T...
test3 NUMBER(3),final_exam NUMBER(3),CONSTRAINT fk_student FOREIGN KEY (stud_id) REFERENCES student(stud_id),CONSTRAINT fk...
INSERT INTO presentation VALUES (ACC200, 1, S001, J02);INSERT INTO presentation VALUES (ACC201, 1, S004, J02);INSERT INTO ...
Md
Upcoming SlideShare
Loading in …5
×

Md

429 views

Published on

macam

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
429
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Md

  1. 1. NOR AMIRAH BT MOHD AMINUDDINB030910199TABLE : STUDENTCREATE TABLE student(stud_id CHAR(4) NOT NULL,student_name VARCHAR2(14),address VARCHAR(20),birthdate DATE,gender VARCHAR2(6),CONSTRAINT student_pk PRIMARY KEY (stud_id));INSERT INTO student VALUES (S001, WENDY JONES, 125 MAPLE AVE, 25-OCT-75, FEMALE);INSERT INTO student VALUES (S002, SAM WALES, 16, NEW STREET, 10-JAN-80, MALE);INSERT INTO student VALUES (S003, ERROL BROWN, 17, HIGH STREET, 22-FEB-77, MALE);INSERT INTO student VALUES (S004, CATHY SMITH, 22, CHILTERN AVE, 31-MAR-77, FEMALE);INSERT INTO student VALUES (S005, JAY LANCER, 2, NORTHERN AVE, 1-MAR-75, FEMALE);INSERT INTO student VALUES (S006, TRACY WILLIAMS, 1, MANCHESTER STREET, 1-JUN-75,FEMALE);INSERT INTO student VALUES (S007, BEN TREVIEND, 17, NORTH STREET, 22-AUG-77, MALE); In the CREATE TABLE student, the address query VARCHAR2 (14) was changed to VARCHAR(20), since the INSERT query for address is too long for certain data.
  2. 2. TABLE: FACULTYCREATE TABLE faculty (fac_id CHAR(3) NOT NULL,lecturer VARCHAR2(20),department VARCHAR2(10),gender VARCHAR2(6),salary NUMBER(6),CONSTRAINT faculty_pk PRIMARY KEY (fac_id));INSERT INTO faculty VALUES (J01, RAY JOHNSON, COMP SCI, MALE, 20000);INSERT INTO faculty VALUES (S01, WENDY JUMPER, COMP SCI, FEMALE, 23000);INSERT INTO faculty VALUES (D01, AMY DANCER, COMP SCI, FEMALE, 28000);INSERT INTO faculty VALUES (J02, ROBERT JONES, ACCOUNTING, MALE, 35000);INSERT INTO faculty VALUES (N01, JACK NELSON, HISTORY, MALE, 28000); Fac_id is assign as the Primary Key, so redundant data cannot be created.TABLE: COURSECREATE TABLE course (course_id CHAR(6) NOT NULL,
  3. 3. course_title VARCHAR2 (30),CONSTRAINT course_pk PRIMARY KEY (course_id));INSERT INTO course VALUES (CSC100, INTRODUCTION TO COMPUTING);INSERT INTO course VALUES (CSC200, JAVA PROGRAMMING);INSERT INTO course VALUES (ACC200, PRINCIPLES OF ACCOUNTING);INSERT INTO course VALUES (ACC201, ADVANCED ACCOUNTING);INSERT INTO course VALUES (HIS200, HISTORY OF FILM); Since, course is the Primary Key. Redundant data in the INSERT query have to be deleted. So, only 5 COURSE_TITLE added.TABLE : GRADECREATE TABLE grade(stud_id CHAR(4) NOT NULL,course_id CHAR(6) NOT NULL,test1 NUMBER(3),test2 NUMBER(3),
  4. 4. test3 NUMBER(3),final_exam NUMBER(3),CONSTRAINT fk_student FOREIGN KEY (stud_id) REFERENCES student(stud_id),CONSTRAINT fk_course FOREIGN KEY (course_id) REFERENCES course (course_id),CONSTRAINT grade_pk PRIMARY KEY (stud_id,course_id));INSERT INTO grade VALUES (S001, CSC200, 98, 95, 93, 92);INSERT INTO grade VALUES (S002, CSC200,88 ,85 ,83 ,82 );INSERT INTO grade VALUES (S003, CSC200, 78, 85, 93, 72);INSERT INTO grade VALUES (S004, CSC200, 68, 65, 73, 62);INSERT INTO grade VALUES (S005, CSC200, 58, 55, 53, 42); Course_id added as the primary key.TABLE: PRESENTATIONCREATE TABLE presentation(course_id REFERENCES course(course_id),semester NUMBER(1) NOT NULL,stud_id REFERENCES student(stud_id),fac_id REFERENCES faculty(fac_id));INSERT INTO presentation VALUES (CSC100, 1, S001, J01);INSERT INTO presentation VALUES (CSC100, 1, S002, S01);INSERT INTO presentation VALUES (CSC200, 1, S003, S01);INSERT INTO presentation VALUES (CSC200, 1, S001, D01);
  5. 5. INSERT INTO presentation VALUES (ACC200, 1, S001, J02);INSERT INTO presentation VALUES (ACC201, 1, S004, J02);INSERT INTO presentation VALUES (HIS200, 1, S005, N01);TABLE: GRADE_SCALECREATE TABLE grade_scale(low_value NUMBER(4,1),high_value NUMBER(4,1),grade CHAR(4)); Table created, but there is no data.

×