ASSIGNMENT 2
VVP
ENGINEERING
COLLEGE
CE DEPARTMENT
SUBMITTED BY: VADOLIYA ABHISHEK
G2
200470107034
Assignment 1
Assignment-2
1) Create table Student_master having following column
Enrollmentno,rollno, mobileno,current_sem,branch,
name,sem_result,batch
- define enrollment no as primary key
- current_sem must be between 1 to 10
- branch must not null
- name must not null
Ans: create table Student_master (Enrollmentno number(12) primary
key, Rollno number(8), Mobile_no number(10), Current_sem
number(1) check (Current_sem>=1 and Current_sem<=10), Branch
varchar2(2) not null, Name varchar2(20) not null, Sem_result
varchar2(4), Batch varchar2(2)) ;
<ENROLLMENTNO TOPIC 1
>
Assignment 1
2) create subject_master having following column
subject_code,subject_name,branch,semester,theory,tutorial,practical,c
redit
- subject_code no as primary key
- semester must be between 1 to 10
- theory,tutorial must be between 0 to 5
- practical must be between 0 to 20
Ans: create table Subject_master (subject_code number(10) primary
key, subject_name varchar2(20),Branch varchar2(2) not null, Semester
number(1) check (semester>=1 and semester<=10), Theory number(1)
check (Theory>=0 and Theory<=5), Tutorial number(1) check
(Tutorial>=0 and Tutorial<=5), Practical number(20) check (Practical>=0
and Practical<=20), Credit number(1));
<ENROLLMENTNO TOPIC 2
>
Assignment 1
3) subject_distribution
subject_distribution_id, enrollmentno,subject_code
- subject_distribution_id must be defined as primary key
- enrollmentno defined as foreign key
- subject_code defined as foreign key
Ans: create table Subject_distribution (Subject_distribution_id
number(10) primary key,
Enrollmentno number(12) references Student_master (Enrollmentno),
Subject_code number(10) references Subject_master(Subject_code));
<ENROLLMENTNO TOPIC 3
>
Assignment 1
4) Perform data insertation as per screenshot
Student_master - http://prntscr.com/tkzngb
Subject_master - http://prntscr.com/tkznsd
subject_distribution - http://prntscr.com/tkzo1j
Ans: Insert into Student_master
(Enrollmentno,Rollno,Name,Mobile_no,Current_sem,Branch,Sem_resu
lt,Batch)
Values
(180470107001,'18CE001','Meet',9825398253,2,'CE','PASS','G1')
Insert into Student_master
(Enrollmentno,Rollno,Name,Mobile_no,Current_sem,Branch,Sem_resu
lt,Batch)
Values
(180470107002,'18CE002','Rahul',9825398254,2,'CE','PASS','G2')
Insert into Student_master
(Enrollmentno,Rollno,Name,Mobile_no,Current_sem,Branch,Sem_resu
lt,Batch)
Values
(180470107003,'18CE003','Anjum',9825398255,2,'CE','PASS','G1')
Insert into Student_master
(Enrollmentno,Rollno,Name,Mobile_no,Current_sem,Branch,Sem_resu
lt,Batch)
Values
(180470107004,'18CE004','Shain',9825398254,2,'CE','FAIL','G3')….
<ENROLLMENTNO TOPIC 4
>
Assignment 1
ii) Subject_master - http://prntscr.com/tkznsd
ANS: Insert into Subject_master
(subject_code,subject_name,branch,semester,theory,tutorial,practical,
credit)
Values (3120701,'EG','CE',2,2,0,4,4)
Insert into Subject_master
(subject_code,subject_name,branch,semester,theory,tutorial,practical,
credit)
Values (3120702,'PPS','CE',2,3,0,2,4)
Insert into Subject_master
(subject_code,subject_name,branch,semester,theory,tutorial,practical,
credit)
Values (3120703,'Maths','CE',2,4,2,0,4)
Insert into Subject_master
(subject_code,subject_name,branch,semester,theory,tutorial,practical,
credit)
Values (3120704,'BE','CE',2,3,0,2,4)
<ENROLLMENTNO TOPIC 5
>
Assignment 1
Insert into Subject_master
(subject_code,subject_name,branch,semester,theory,tutorial,practical,
credit)
Values (3130703,'DBMS','CE',3,4,0,2,5)
Insert into Subject_master
(subject_code,subject_name,branch,semester,theory,tutorial,practical,
credit)
Values (3130704,'DS','CE',3,3,0,4,5)
Insert into Subject_master
(subject_code,subject_name,branch,semester,theory,tutorial,practical,
credit)
Values (3130705,'DF','CE',3,4,0,2,4)
Insert into Subject_master
(subject_code,subject_name,branch,semester,theory,tutorial,practical,
credit)
Values (3130706,'Maths','CE',3,4,2,0,4)
<ENROLLMENTNO TOPIC 6
>
Assignment 1
iii) subject_distribution - http://prntscr.com/tkzo1j
Ans: Insert into Subject_DISTRIBUTION (subject_distribution_id,
enrollmentno,subject_code)
Values (1,180470107001,3130703)
Insert into Subject_DISTRIBUTION (subject_distribution_id,
enrollmentno,subject_code)
Values (2,180470107001,3130704)
Insert into Subject_DISTRIBUTION (subject_distribution_id,
enrollmentno,subject_code)
Values (3,180470107001,3130705)
Insert into Subject_DISTRIBUTION (subject_distribution_id,
enrollmentno,subject_code)
Values (4,180470107001,3130706)
Insert into Subject_DISTRIBUTION (subject_distribution_id,
enrollmentno,subject_code)
Values (5,180470107002,3130703)
Insert into Subject_DISTRIBUTION (subject_distribution_id,
enrollmentno,subject_code)
Values (6,180470107002,3130704)
Insert into Subject_DISTRIBUTION (subject_distribution_id,
enrollmentno,subject_code)
Values (7,180470107002,3130705)
Insert into Subject_DISTRIBUTION (subject_distribution_id,
enrollmentno,subject_code)
Values (8,180470107002,3130706)
<ENROLLMENTNO TOPIC 7
>
Assignment 1
5) total subject learned by Chris
Ans: select SUBJECT_NAME,SUBJECT_CODE from STUDENT_MASTER
LEFT JOIN SUBJECT_MASTER on
STUDENT_MASTER.CURRENT_SEM=SUBJECT_MASTER.SEMESTER
where Name='Chris'
6) total credit earned by Meet after clearing second sem exam
Ans: select SUM(CREDIT) from SUBJECT_MASTER RIGHT JOIN
STUDENT_MASTER
on STUDENT_MASTER.CURRENT_SEM=SUBJECT_MASTER.SEMESTER
where Name='Meet'
<ENROLLMENTNO TOPIC 8
>
Assignment 1
7) update current_sem to 3 for all students who clears the exam
Ans: UPDATE STUDENT_MASTER SET CURRENT_SEM=3 WHERE
SEM_RESULT='PASS'
8) total theory needs to be attended by 3rd semester students
result should be display like
Name, total_theory_count
Ans: SELECT NAME,SUM(THEORY) TOTAL_THEORY
FROM STUDENT_MASTER
INNER JOIN SUBJECT_MASTER ON
STUDENT_MASTER.CURRENT_SEM=SUBJECT_MASTER.SEMESTER
GROUP BY Name
<ENROLLMENTNO TOPIC 9
>
Assignment 1
9) total practical needs to be attend by 3rd semester students
result should be display like
Name, total_practical_count
Ans: SELECT NAME,SUM(PRACTICAL) TOTAL_PRACTICAL
FROM STUDENT_MASTER
INNER JOIN SUBJECT_MASTER ON
STUDENT_MASTER.CURRENT_SEM=SUBJECT_MASTER.SEMESTER
GROUP BY Name
<ENROLLMENTNO TOPIC 10
>
Assignment 1
10) list subjects order by subject_code
Ans: SELECT SUBJECT_CODE,SUBJECT_NAME FROM SUBJECT_MASTER
ORDER BY SUBJECT_CODE
<ENROLLMENTNO TOPIC 11
>