You are on page 1of 33

KRISHNA ENGINEERING COLLEGE

(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

Practical no……………………….Name of the practical…………………………………..


Student Roll no..…………………Student Name………………Semester/Batch………..
Assignment – I
Q. Draw the ER Model for the Office of the Controller of Examinations
Application. Convert this model to relational schemas, so as to finally create the
following tables.
Create the tables with the constraints specified and answer the subsequent
questions.
CREATE TABLE PRACHI_DEPARTMENT (DNO NUMBER (2), DNAME VARCHAR2 (20));
ALTER TABLE PRACHI_DEPARTMENT ADD PRIMARY KEY (DNO);
CREATE TABLE PRACHI_BRANCH (BCODE NUMBER (3), BNAME VARCHAR2 (25), DNO NUMBER (2));
ALTER TABLE PRACHI_BRANCH ADD PRIMARY KEY (BCODE);
ALTER TABLE PRACHI_BRANCH ADD FOREIGN KEY (DNO) REFERENCES PRACHI_DEPARTMENT (DNO);
CREATE TABLE PRACHI_BRANCH_COURSE (BCODE NUMBER (3), CCODE NUMBER (4), SEMESTER NUMBER (2));
ALTER TABLE PRACHI_BRANCH_COURSE ADD PRIMARY KEY (BCODE, CCODE);
ALTER TABLE PRACHI_BRANCH_COURSE ADD FOREIGN KEY (BCODE) REFERENCES PRACHI_BRANCH (BCODE);
ALTER TABLE PRACHI_BRANCH_COURSE ADD FOREIGN KEY (CCODE) REFERENCES PRACHI_COURSE (CCODE);
CREATE TABLE PRACHI_STUDENT (ROLLNO NUMBER (5),NAME VARCHAR2 (20), DOB DATE, GENDER CHAR(2), DOA DATE, BCODE
NUMBER (3));
ALTER TABLE PRACHI_STUDENT ADD PRIMARY KEY (ROLLNO);
ALTER TABLE PRACHI_STUDENT ADD FOREIGN KEY (BCODE) REFERENCES PRACHI_BRANCH (BCODE);
ALTER TABLE PRACHI_STUDENT ADD CONSTRAINT CHK CHECK (GENDER IN ('M', 'F'));
ALTER TABLE PRACHI_STUDENT ADD CONSTRAINT CHK2 CHECK (DOA < TO_DATE('31-4-2016, 'DD-MM-YYYY');
CREATE TABLE PRACHI_COURSE (CCODE NUMBER (4), CNAME VARCHAR2 (25), CREDITS NUMBER (2), DNO NUMBER (2));
ALTER TABLE PRACHI_COURSE ADD PRIMARY KEY (CCODE);
ALTER TABLE PRACHI_COURSE ADD FOREIGN KEY (DNO) REFERENCES PRACHI_DEPARTMENT (DNO));
CREATE TABLE PRACHI_ENROLLS (ROLLNO NUMBER (5), CCODE NUMBER (4), SESS VARCHAR2 (15), GRADE CHAR (2));
ALTER TABLE PRACHI_ENROLLS ADD PRIMARY KEY (ROLLNO, CCODE, SESS);
ALTER TABLE PRACHI_ENROLLS ADD FOREIGN KEY ROLLNO) REFERENCES PRACHI_STUDENT (ROLLNO);
ALTER TABLE PRACHI_ENROLLS ADD FOREIGN KEY (CCODE) REFERENCES PRACHI_COURSE (CCODE);
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering
INSERT INTO PRACHI_DEPARTMENT
INSERT INTO PRACHI_DEPARTMENT
INSERT INTO PRACHI_DEPARTMENT
INSERT INTO PRACHI_DEPARTMENT
INSERT INTO PRACHI_DEPARTMENT
INSERT INTO PRACHI_DEPARTMENT
INSERT INTO PRACHI_DEPARTMENT VALUES(11, 'ITCS');
VALUES (1, 'MATHS');
VALUES (2, 'DBMS');
VALUES (3, 'DAA');
VALUES (4, 'ML');
VALUES (5, 'CD');
VALUES (6, 'CSS');
INSERT INTO PRACHI_COURSE VALUES (1011, 'ALGEBRA', 2,1);
INSERT INTO PRACHI_COURSE VALUES (1012, 'TRIGNOMETRY', 3,1);
INSERT INTO PRACHI_COURSE VALUES (1013, 'MATH', 2,1);
INSERT INTO PRACHI_COURSE VALUES (1014, 'STATISTICS', 2,1);
INSERT INTO PRACHI_COURSE VALUES (1021, 'ANALYSIS', 3,1);
INSERT INTO PRACHI_COURSE VALUES (1022, 'COMPLEX ', 4,1);
INSERT INTO EHA_COURSE VALUES (1023, 'THEORY', 4,1);
INSERT INTO PRACHI_COURSE VALUES (1024, 'EQUATION', 3,1);
INSERT INTO PRACHI_COURSE VALUES (1051, 'CALCULAS', 2,1);
INSERT INTO PRACHI_COURSE VALUES (1052, 'MATH IV', 3,1);
INSERT INTO PRACHI_COURSE VALUES (1061, 'GRAPHICS', 3,1);
INSERT INTO PRACHI_COURSE VALUES (1062, 'PROGRAMMING', 3,1);
INSERT INTO PRACHI_COURSE VALUES (1063, 'SOLIDS', 2,1);
INSERT INTO PRACHI_BRANCH (109, 'CSE',1);
INSERT INTO PRACHI_BRANCH (110, 'IT', 2);
INSERT INTO PRACHI_BRANCH(111, 'MECH', 3);
INSERT INTO PRACHI_BRANCH (109, 'ECE', 4);
INSERT INTO PRACHI_BRANCH (111, 'AI/ML',5);
INSERT INTO PRACHI_BRANCH (110, 'EC', 6);
INSERT INTO PRACHI_BRANCH (109, 'ME', 11);
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

INSERT INTO PRACHI_BRANCH_VALUES(109, 1011,3);


PRACHI_BRANCH_VALUES(110,1012,5);
INSERT INTO
INSERT INTO PRACHI_BRANCH_VALUES (109, 1013, 7);
INSERT INTO PRACHI_BRANCH_VALUES(111,1014, 2);
INSERT INTO PRACHI_BRANCH_VALUES (110, 1021,6);
INSERT INTO PRACHI_BRANCH_VALUES (109, 1022,5);
INSERT INTO PRACHI_BRANCH_VALUES(110,1023,3);
INSERT INTO PRACHI_BRANCH_VALUES (110,1024,1);
INSERT INTO PRACHI_BRANCH_VALUES(111,1051,8);
INSERT INTO PRACHI_BRANCH_VALUES(110,1052,4);
INSERT INTO PRACHI_BRANCH_VALUES(111,1061, 3);
INSERT INTO
PRACHI_BRANCH_VALUES (109, 1062, 2);
INSERT INTO PRACHI_BRANCH_VALUES (110,1063,8);

INSERT INTO PRACHI_STUDENT VALUES ( 12001, 'PRACHI VERMA', TO_DATE( '3-4-1989',DD-MM-YYYY')


'F' TO_DATE('24-4-2016', 'DD-MM-YYYY'), 110);
INSERT INTO PRACHI_STUDENT VALUES (12002, 'ANKUR KUMAR', TO_DATE( '15-3-1999', DD-MM-YYYY')
, 'M', TO_DATE( '20-5-2016', 'DD-MM-YYYY'), 111);
INSERT INTO PRACHI STUDENT VALUES (12005, 'ASHA DEVI', TO_DATE( '30-5-1991', DD-MM-YYYY')
, 'F'
TO_DATE('2-4-2017', 'DD-MM-YYYY'), 109);
INSERT INTO PRACHI_STUDENT VALUES (12003, 'SHISHIR KUMAR', TO_DATE( '29-6-1988', DD-MM-YYYY')
'M' TO_DATE( '16-5-2016', 'DD-MM-YYYY'), 110);
‫ر‬
>
INSERT INTO PRACHI_STUDENT VALUES (12004, 'PREETI', TO_DATE( '1-1-1987', DD-MM-YYYY')
'F'
, TO_DATE( '4-4-2017', 'DD-MM-YYYY'), 110);
INSERT INTO PRACHI_STUDENT VALUES (12006, 'SHREYA', TO_DATE( '18-9-1989',DD-MM-YYYY')
, 'F'
TO_DATE( '12-3-2015', 'DD-MM-YYYY'), 111);
INSERT INTO PRACHI_STUDENT VALUES (12007, 'SUBHAM', TO_DATE( '8-9-1999', DD-MM-YYYY')
'M' TO_DATE('18-8-2017', 'DD-MM-YYYY'), 109);
INSERT INTO PRACHI_STUDENT VALUES (12023, 'PRIYA', TO_DATE( '4-11-1990', DD-MM-YYYY')
'F' TO_DATE( '11-9-2015', 'DD-MM-YYYY'), 111);

INSERT INTO PRACHI_ENROLLS VALUES ( 12001, 1012, 'MAY2014','S');


INSERT INTO PRACHI_ENROLLS VALUES ( 12001, 1011, 'JUNE 2014', 'S');
INSERT INTO PRACHI_ENROLLS VALUES ( 12005, 1013, 'JULY2014', 'S');
INSERT INTO PRACHI_ENROLLS VALUES ( 12005, 1014, 'SEP2008','S');
'AUGUST2008', 'A');
'APRIL2012', 'B');
'MAY2008', 'D');
'NOV2013', 'C');
'JUNE 2013', 'U');
JULY2012', 'E');
'SEP2012', 'A');
INSERT INTO PRACHI_ENROLLS VALUES (12002, 1022,
INSERT INTO PRACHI_ENROLLS VALUES(12002, 1021,
INSERT INTO PRACHI_ENROLLS VALUES ( 12003, 1101,
INSERT INTO PRACHI_ENROLLS VALUES ( 12007, 1102,
INSERT INTO PRACHI_ENROLLS VALUES(12004, 1113,
INSERT INTO PRACHI_ENROLLS VALUES( 12004, 1113,
INSERT INTO PRACHI_ENROLLS VALUES ( 12006, 1084,
SELECT * FROM PRACHI_DEPARTMENT D WHERE D.DNO IN (SELECT B.DNO FROM PRACHI_BRANCH B
GROUP BY B.DNO HAVING COUNT (B.DNO) > 3);
SELECT * FROM PRACHI_DEPARTMENT D WHERE D.DNO IN (SELECT C.DNO FROM PRACHI_COURSE C
GROUP BY C.DNO HAVING COUNT (C.CCODE) > 6);
SELECT * FROM PRACHI_COURSE C WHERE C.CCODE IN (SELECT B.CCODE FROM PRACHI_BRANCH_COURSE B
GROUP BY B.CCODE HAVING COUNT (B.BCODE) > 3);
SELECT * FROM PRACHI_STUDENT S WHERE S.ROLLNO IN (SELECT E.ROLLNO FROM PRACHI_ENROLLS E
WHERE E.GRADE = 'S' GROUP BY E.ROLLNO HAVING COUNT (E.GRADE) > 2);
CREATE VIEW PRACHI_STUDATA AS SELECT E.ROLLNO, S.NAME, COUNT (E.CCODE) AS CC FROM PRACHI_STUDENT S,
PRACHI_ENROLLS E WHERE E.ROLLNO = S.ROLLNO AND E.GRADE != 'U' GROUP BY E.ROLLNO, S.NAME;
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

Session 2022-23 ODD semester

Practical no……………………….Name of the practical…………………………………..


Student Roll no..…………………Student Name………………Semester/Batch………..

Assignment of Sql queries and join queries.


KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

2.

3.

PRACHI
HARSH
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

4.

5.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

6.

7.

8.

9.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

--10

11

12
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

13
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

14

15
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

---

16
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

17
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

18

19

20
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

Join queries

1.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

2.

3.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

4.

5.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

---

6.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

7.

8.

9.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

10.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

Session 2022-23 ODD semester

Practical no……………………….Name of the practical…………………………………..


Student Roll no..…………………Student Name………………Semester/Batch………..

1. Write a PL/SQL program to check whether a number is even or odd.

2. Write a PL/SQL procedure to calculate the incentive on a specific target otherwise a general
incentive to be paid using IF-THEN-ELSE.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

3. Write a PL/SQL program to convert a temperature in scale Fahrenheit to Celsius and vice
versa.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

4. Write a program in PL/SQL to show the uses of nested loop.

5. Write a program in PL/SQL to update the salary of a specific employee by 8% if the salary
exceeds the mid-range of the salary against this job and update up to mid-range if the salary is
less than the mid-range of the salary, and display a suitable message.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

6. Write a program in PL/SQL to insert records from one table to another.


KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

7. Write a program in PL/SQL to print the prime numbers between 1 to 50.

8. Write a PL/SQL block to describe the usage of LIKE operator including wildcard
characters and escape character.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

9. CREATE a PROCEDURE without parameters.

10. CREATE a PROCEDURE using Input Parameters.

11. CREATE a PROCEDURE using Output Parameters.


KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

12. Create a Procedure for Modifying data using a Stored Procedure.


KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

Session 2022-23 ODD semester

Practical no……………………….Name of the practical…………………………………..


Student Roll no..…………………Student Name………………Semester/Batch………..

1.Write a program in PL/SQL to retrieve the records from the employees table and display those using
cursors.

1. Write a program in PL/SQL to show the uses of SQL%FOUND to determine if a DELETE


statement affected any rows.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

2. Write a PL/SQL block to display department name, head of the department, city, and
employee with highest salary.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

3. The HRD manager has decided to raise the salary for all the employees in department number 20
by 0.05. Whenever any such raise is given to the employees, record for the same is maintained in the
emp_raise table. It includes the employee number, the date when the raise was given the actual raise.
Write a PL/SQL block to update the salary of each employee and insert a record in the emp_raise table.
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

4. Given Student Report Database, in which student marks assessment is recorded. In such schema,
create a trigger so that the total and percentage of specified marks is automatically inserted whenever a
record is insert.
The table schema for Student Report is as follows:
Field | Type | Null | Key | Default | Extra |
+++++++
| tid| int(4)| NO| PRI | NULL| auto_increment |
| name | varchar(30) | YES | | NULL | |
| subj1 | int(2)| YES | | NULL | |
| subj2 | int(2)| YES | | NULL | |
| subj3 | int(2)| YES | | NULL | |
| total | int(3)| YES | | NULL | |
| per| int(3)| YES || NULL | |
+++++
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering

You might also like