Vous êtes sur la page 1sur 11

ASSIGNMENT-2

TABLES
APPLICANT:-
CREATE TABLE APPLICANT(

APPLICANT_ID VARCHAR(4),

APPLICANT_NAME VARCHAR(30) NOT NULL,

EMAIL_ID VARCHAR(30),

ADDRESS VARCHAR(50),

CITY VARCHAR(15),

CONSTRAINT PK_APP1 PRIMARY KEY(APPLICANT_ID),

CONSTRAINT U_APP1 UNIQUE(EMAIL_ID));

BRANCH:-
CREATE TABLE BRANCH(

BRANCH_ID VARCHAR(2) PRIMARY KEY,

BRANCH_NAME VARCHAR(30) NOT NULL,

CONSTRAINT CK_BR CHECK(BRANCH_ID LIKE 'B%'));

COURSE:-
CREATE TABLE COURSE(

COURSE_ID VARCHAR(4),

COURSE_NAME VARCHAR(30) NOT NULL,

SEMESTER NUMBER(1),
BRANCH_ID VARCHAR(2),

ELECTIVE CHAR(1),
PROJECT_MARKS NUMBER(3),

ASSIGNMENT_MARKS NUMBER(3),

INTERNAL_MARKS NUMBER(3),

SEMESTER_EXAM_MARKS NUMBER(3),

CONSTRAINT PK_COUR1 PRIMARY KEY(COURSE_ID),

CONSTRAINT FK_COUR1 FOREIGN KEY(BRANCH_ID) REFERENCES BRANCH(BRANCH_ID),


CONSTRAINT CHK_COUR1 CHECK(ELECTIVE LIKE 'Y' OR ELECTIVE LIKE 'N'));

STUDENT:-
CREATE TABLE STUDENT(

STUDENT_ID VARCHAR(4),

APPLICANT_ID VARCHAR(4),

CURRENT_SEMESTER NUMBER(1),

USER_ID VARCHAR(15),

PASSWORD VARCHAR(15) NOT NULL,

CONSTRAINT PK_STUD1 PRIMARY KEY(STUDENT_ID),

CONSTRAINT FK_STUD1 FOREIGN KEY(APPLICANT_ID) REFERENCES APPLICANT(APPLICANT_ID),

CONSTRAINT UNQ_STUD1 UNIQUE(USER_ID));

REGISTRATION:-
CREATE TABLE REGISTRATION(

STUDENT_ID VARCHAR(4),

COURSE_ID VARCHAR(4),

DATE_OF_EXAM DATE,

PROJECT_MARKS NUMBER(3),

ASSIGNMENT_MARKS NUMBER(3),

INTERNAL_MARKS NUMBER(3),

SEMESTER_MARKS NUMBER(3),

GRADE CHAR(1),
CONSTRAINT FK_REG1 FOREIGN KEY(STUDENT_ID) REFERENCES STUDENT(STUDENT_ID),

CONSTRAINT FK_REG2 FOREIGN KEY(COURSE_ID) REFERENCES COURSE(COURSE_ID));

DEPARTMENT:-
CREATE TABLE DEPARTMENT(

DEPARTMENT_ID NUMBER(2),

DEPARTMENT_NAME VARCHAR(30) NOT NULL,

HEAD_OF_DEPARTMENT VARCHAR(4),

CONSTRAINT PK_DEPART1 PRIMARY KEY(DEPARTMENT_ID));

INSTRUCTOR:-
CREATE TABLE INSTRUCTOR(

INSTRUCTOR_ID VARCHAR(4),

INSTRUCTOR_NAME VARCHAR(30) NOT NULL,

DATE_OF_JOINING DATE,

DEPARTMENT_ID NUMBER(2),

CONSTRAINT PK_INST1 PRIMARY KEY(INSTRUCTOR_ID),

CONSTRAINT FK_INST1 FOREIGN KEY(DEPARTMENT_ID) REFERENCES


DEPARTMENT(DEPARTMENT_ID));

DEPARTMENT:-
ALTER TABLE DEPARTMENT ADD CONSTRAINT FK_DEPART1 FOREIGN
KEY(HEAD_OF_DEPARTMENT) REFERENCES INSTRUCTOR(INSTRUCTOR_ID);

COURSE_ALLOCATION:-
CREATE TABLE COURSE_ALLOCATION(

ALLOCATION_ID VARCHAR(4),
COURSE_ID VARCHAR(4),
INSTRUCTOR_ID VARCHAR(4),

START_DATE DATE,

END_DATE DATE,

CONSTRAINT PK_CA1 PRIMARY KEY(ALLOCATION_ID),

CONSTRAINT FK_CA1 FOREIGN KEY(COURSE_ID) REFERENCES COURSE(COURSE_ID),

CONSTRAINT FK_CA2 FOREIGN KEY(INSTRUCTOR_ID) REFERENCES


INSTRUCTOR(INSTRUCTOR_ID),

CONSTRAINT CK_CA1 CHECK(END_DATE > START_DATE));

HOSTEL:-
CREATE TABLE HOSTEL(

HOSTEL_ID VARCHAR(10),

ROOM_NO NUMBER(3),

STUDENT_ID VARCHAR(4),

HOSTEL_FEE NUMBER(6),

CONSTRAINT PK_HOST1 PRIMARY KEY(HOSTEL_ID,ROOM_NO),

CONSTRAINT FK_HOST1 FOREIGN KEY(STUDENT_ID) REFERENCES STUDENT(STUDENT_ID),

CONSTRAINT CK_HOST1 CHECK(HOSTEL_FEE > 0));

ATTENDANCE:-
CREATE TABLE ATTENDANCE(

STUDENT_ID VARCHAR(4),

COURSE_ID VARCHAR(4),

TOTAL_LECTURE_DAYS NUMBER(3),

NO_OF_DAYS_PRESENT NUMBER(3),

CONSTRAINT FK_ATTEN1 FOREIGN KEY(STUDENT_ID) REFERENCES STUDENT(STUDENT_ID),

CONSTRAINT FK_ATTEN2 FOREIGN KEY(COURSE_ID) REFERENCES COURSE(COURSE_ID),

CONSTRAINT CK_ATTEN1 CHECK(TOTAL_LECTURE_DAYS > 0));


QUESTIONS & ANSWERS:-
1. List the name of different cities from where applicants belong to.

2. List the different semesters in which students have enrolled.

3. List the distinct InstructorId and courseid from CourseAllocation table.

4. List the name of course which are not electives.


5. List the name of instructor who has joined before 01-jan-2002

6. List Id of courses whose ending date is before the current system date.

7. List the name of applicant from Mysore and Bangalore

8. List the name of applicants who do not belong to Mysore.


9. List the name of semester 1 and semester 2 courses which belongs to branch B1.

10. List the name of courses which are elective and project marks is equal to 20.

11. List the name of the course in which project marks is greater than the semester marks.

12. List the details of all the applicant who belong to Bangalore, Mysore or Hydrabad
13. List the details of courses which are taught in semester 1, 2 or 3.

14. List the studentId who have secured marks between 80 to 100.
15. List the student details in ascending order of their applicantid.

16. List the details of instructor on ascending order of their date of joining.
17. List the details of instructor on descending order of department no and ascending order
of Joining date.

18. List the name of instructors starting with R and ending with n

19. List the details of instructors whose date of joining is in the month of March.

20. List the details of applicant whose email id contains a character n


21. List the applicant who do not have email id in their applicant detail information .

22. List the course Id which has project Marks in its course detail information.

Vous aimerez peut-être aussi