Sei sulla pagina 1di 10

The following are the required tables to be created:

Table Name Description


Courses Contains the details of all the courses offered by the institute.
Faculty Contahins the details of the faculty members of the institute.
Course_faculty This table contains information regarding which faculty can handle
which course. It also contains rating regarding how good a faculty
member is in handling a particular course. The rating is based on
previous experience of the faulty member with that course.
Batches Contains the information about all the batches. It contains information
about all the batches that started and completed, on going and scheduled
but not yet started.
Students Contains information about all the students. Each student is assigned a
new roll number whenever he/she joins a new course.
Payments Information about all the payments made by students. A single student
may pay course fee in multiple installments for a single course.

COURSES Table

Q1: Create a table Courses that Contains information related to each course. Each course is given a
unique code called course code.

Column Name Data Type Description


CCODE VARCHAR2(5) Course Code. This is the primary key of the table.

NAME VARCHAR(30) Name of the course.


DURATION NUMBER(3) Duration of the course in no. of working days.
FEE NUMBER(5) Course fee of the course.
PREREQUISITE VARCHAR2(100) Prerequisite knowledge to do the course.

The following are the required constraints of COURSES table.

1 CCODE is primary key.


2 FEE must be greater than or equal to 0.
3 DURATION must be greater than or equal to 0.
FACULTY Table

Q2: Create a table Faculty that Contains information about all the faculty members. Each faculty
member is given a code called as FACCODE.

Column Name Data Type Description

FACCODE VARCHAR2(5) Faculty code. This is the primary key of the table.

NAME VARCHAR2(30) Name of the faculty.


QUAL VARCHAR2(30) Qualification of the faculty member.
EXP VARCHAR2(100) Experience of the faculty member.

The following are the constraints of FACULTY table.

1 FACCODE is primary key.

COURSE_FACULTY table

Q3: Create a table Course_Faculty that Contains information regarding which faculty member can
take which course. A single faculty member may be capable of handling multiple courses. However,
each member is given a grade depending on his expertise in handling the subject. The grade will be
wither A, B or C.

Column Name Data Type Description

FACCODE VARCHAR2(5) Faculty code.

CCODE VARCHAR2(5) Course the faculty can handle.

GRADE CHAR(1) Rating of faculty’s ability to handle this particular


code.
A – Very good, B- Good,
C- Average.

The following are the constraints of the table.


1 FACCODE is a foreign key referencing FACCODE column of FACULTY table.
2 CCODE is a foreign key referencing CCODE column of COURSEtableS .
3 Primary key is consisting of FACCODE and CCODE.
4 GRADE column must contain either A, B or C.
Batches table

Q4: Create a table Batches that Contains information about all the batches. These batches include
batches that were completed, that are currently running and that are scheduled but yet to start.

Column Name Data Type Description


BCODE VARCHAR2(5) Code that is assigned to each batch. This is the primary
key of the table.
CCODE VARCHAR2(5) Course code of the course of this batch. This is a foreign
key referencing CCODE of COURSES table.

FACCODE VARCHAR2(5) Code of the faculty member taking this batch.

STDATE DATE Date on which the batch has started or scheduled to start
if batch has not yet started.
ENDDATE DATE Date on which the batch has completed. If batch is not
completed this will be null.
TIMING NUMBER(1) Number indicating the timing of the batch. 1- morning,
2 – after noon, and 3-evening.

The following are the required constraints of this table.

1 BCODE is the primary key.


2 CCODE is a foreign key referencing CCODE of COURSES table.
3 FACCODE is a foreign key referencing FACCODE of FACULTY table.
4 STDATA must be <= ENDDATE
5 TIMING column must be 1, 2 or 3.

STUDENTS table

Q5: Create a table Students that Contains information about all the students of the institute. Each
student is given a roll number. Roll number will be allotted to each student of each batch.

Column Data Type Description


Name
ROLLNO NUMBER(5) Roll number that is assigned to each student. This is the
primary key of the table.
BCODE VARCHAR2(5) Code of the batch to which student belongs. This is the
foreign key referencing BCODE of BATCHES table.
NAME VARCHAR2(30) Name of the student.
GENDER CHAR(1) Gender of the student. M for male and F for female.
DJ DATE Date on which the student has joined.
PHONE VARCHAR2(10) Contact number of the student.
EMAIL VARCHAR2(30) Email address of the student.

The following are the constraints of the table.

1 ROLLNO is the primary key.


2 BCODE is a foreign key referencing BCODE of BATCHES table.
3 GENDER may be either M or F.

PAYMENTS table

Q6: Create a table Payments that Contains information about all the payment made by students of all
bathes.

Column Data Type Description


Name
ROLLNO NUMBER(5) Roll number of the student paying the fee.
DP DATE Date on which the amount is paid.
AMOUNT NUMBER(5) The amount paid by student.

The following are the constraints.

1 Primary key is consisting of ROLLNO and DP.


2 AMOUNT must be >= 25
Inserting rows into tables
------------------------ COURSES ----------------------------
CCODE NAME FEE PREREQUISITE DURATION
Ora Oracle database 25,4500 Windows
Vbnet VB.NET 30,5500 Windows and programming Insert data in each
C C programming 20,3500 Computer Awareness row according to
Asp ASP.NET 25,5000 Internet and programming given description
Java Java Language 25,4500 C language using update
Xml XML Programming 15, 4000 'HTML, Scripting, ASP/JSP command.
----------------------------- FACULTY ----------------------------
FACCODE NAME QUAL EXP
gk George Koch MS Computer Science 15 years with databases
da Dan Appleman CS and EE graduate Extensively worked with COM
hs Herbert Schildt MS Computer Science Author of several books
dh David Hunter MS Electronics Extensively worked with Internet Technologies
sw Stephen Walther Ph.D. in Philosophy Extensively worked with Internet Technologies
kl Kevin Loney MS Electronics Specialized in Oracle DBA
jj Jamie Jaworski Bachelor of Electrical Developed programs for US defence department
jc Jason Couchman OCP DBA Published articles on Oracle

------------------------- COURSE_FACULTY ------------------------


FACCODE CCODE GRADE
gk ora A
jc ora A
kl ora A
da vbnet A
sw asp A
da asp B
hs c A
dh xml A
jj java A
hs java B
jj c A
jj vbnet B

------------------------- BATCHES ---------------------------


BCODE CCODE FACCODE STDATE ENDDATE TIMING
b1 ora Gk 12-jan-2018 20-feb-2018 1
b2 asp Da 15-jan-2018 5-mar-2018 2
b3 c Hs 20-jan-2018 27-febr-2018 3
b4 xml Dh 02-mar-2018 30-mar-2018 3
b5 java Hs 05-apr-2018 10-may-2018 1
b6 vbnet Da 12-jul-2018 null 1
b7 ora Jc 15-aug-2018 null 2
---------------------------- STUDENTS ----------------------------
ROLLNO BCODE NAME GENDER DJ PHONE EMAIL
1 b1 George Micheal M 10-jan-2018 488333 gm@yahoo.com
2 b1 Micheal Douglas M 11-jan-2018 334333 md@gmail.com
3 b2 Andy Roberts M 11-jan-2018 433554 ar@yahoo.com
4 b2 Malcom Marshall M 16-jan-2018 653345 mm@usa.net
5 b2 Vivan Richards M 16-jan-2018 641238 vr@yahoo.com
6 b3 Chirs Evert F 14-jan-2018 null ce@yahoo.com
7 b3 Ivan Lendal M 15-jan-2018 431212 il@gmail.com
8 b4 George Micheal M 1-mar-2018 488333 gm@gmail.com
9 b5 Richard Marx M 6-apr-2018 876567 rm@gmail.com
10 b5 Tina Turner F 6-apr-2018 565678 tinat@gmail.com
11 b5 Jody Foster F 7-apr-2001 234344 jody@hotmail.com

---------------------------- PAYMENTS --------------------------


ROLLNO DP AMOUNT
1 10-jan-2018 4500
2 11-jan-2018 3500
2 17-jan-2018 1000
3 13-jan-2018 2000
3 20-jan-2018 3000
4 16-jan-2018 3000
4 30-jan-2018 2000

Queries for altering, dropping, and constraints:


Q1: Add a new column CAT (category) as a NOT NULL to COURSES table.
Q2: Add a constraint which specifies that the column CAT should have at least two characters.
Q3: Increase the size of the column CAT to 10.
Q4: Decrease the size of the column CAT to 5.
Q5: Add a new column rating to COURSES table.
Q6: Modify data type of column rating to number(5) in COURSES table.
Q7: Drop a constraint given to CAT column of course table.
Q8: Drop PRIMARY KEY constraint of Courses along with related constraints.
Q9: Drop column CAT of COURSES table.
Q10: Drop column FCODE column of FACULTY table along with all depending constraints.
Q11: Mark column CAT or COURSES table as unused.
Q12: Drop all columns marked as an unused.
Q13: Disable the primary key of courses table.
Q14: Enable the primary key of courses table.
Q15: Disable a constraint given to CAT column of course table.
Q16: Enable a constraint given to CAT column of course table.
Q17: Drop faculty table.
Queries on select, insert, delete, and update:

Q1: Delete row(s) where CCODE is “c”.


Q2: Change course fee of ASP to 6000.
Q3: Change course fee of ASP to 6000 and duration to 30
Q4: Displays the name of the student and number of days between system date and date of joining.
Q5: Show the name, date of joining and the due date for first installment (assuming first installment is to be
paid within 10 days from the date of joining) of a student.
Q6: Display the details of the payment that were made in the last 3 days .

Queries related to Date functions.

Q1: Show the batch code, course code, end date of course and the date on which the students of completed
batches will be issued certificates assuming it will take 3 months time to issue certificates.
Q2: Display batch code, course code, start date, end date and the number of months between starting date
and ending date of all completed batches.
Q3: Displays the batches that we completed in the last 6 months and duration is more that 1 month.
Q4: Return the last day of the month in which batch has started and if 5 is added to that then it will be 5th of
the next month – due date of first installment.
Q5: Display the date of the next Friday.
Q6: Displays the details of the payments made today.

Queries on Arithmetic, String and Scientific Functions

Q1: Displays the course fee by rounding it to thousands.


Q2: Display concatenated name of the faculty with qualification. And also put two spaces between these two
values to provide required space.
Q3: Retrieve details of courses related to programming.
Q4: Retrieve details of courses related to programming without considering the case.
Q5: Displays the details of courses where the letter ‘g’ exists in the name of the course after 7th position.
Q6: Displays the first 2 character from the code of the course.
Q7: Display name, first name, and last name of the faculty. (name before space is first name and after space
is last name.)
Q8: Displays payments made in the month of April.
Q9: Display the details of the students who have joined in the month of April in year 2018 using to_char
function.
Q10: inserts a new row into PAYMETS table with date as well as time.
Q11: Display faculty code, course code, grade obtained. Grade should be displayed as A should be displayed
as ‘Very Good’ , B as ‘Good’, C as ‘Average’, and any other value of grade as ‘Unknown’.
Q12: Display course details along with the discount announced in a scheme. The scheme is to given discount
of 10% on the course fee or 500 whichever is higher.
Q13: Display batch code, starting date, no. of days (total no. of days course has ran or running),the status of
the batch, which will be COMPLETED if ENDDATE is not null otherwise RUNNING.
Q14: Display course name to 12 characters (dot is to be used for padding).

Insert,Delete and update


Q1: Increase the FEE of the course if more than 5 batches have started for that course.
Q2: Delete the batches for which there are no students.
Q3: updates FCODE of batch b7 to the faculty code of the batch b1.
Q4: update year in STDATE and ENDATE of batches table to 2019;
Q5: update year in DJ of students table to 2019.
Q6: update year in DP of payments table to 2019.
Q7: insert the following data in course table (‘cs’, C Sharp’, 7000)
Group by, having, aggregate
Q1: Display the highest course fee.
Q2: Display the number of students we have in each batch.
Q3: Display the total amount of fee paid by each student.
Q4: Display how many students have made some payment.
Q5: Display the subject and date on which the most recent batch of that subject has started.
Q6: Display the number of batches that started for each subject in the last 3 months.
Q7: Displays the date on which the last batch was taken by each faculty for each subject.
Q8: Display courses that have got more than 1 batch.
Q9: Display the courses that we started for more than once in the last six months.
Q10: Display the number of courses taught by each faculty in the increasing order of their course count.
Joins and set operators
Q1: Display the details of batches that are completed along with name of the course.
Q2: Display the details of batches along with name of the course and name of the faculty.
Q3: Display the details of batches that started after batch B3.
Q4: Display course information which has some batches along with their batch details according to
alphabetical order of course code.

Nested Queries
Q1: Get the details of students who have paid today.
Q2: Display the details of batches handled by faculty name ‘Kevin Loney’.
Q3: Display the details of the faculty members who have not taken any batch in the last three months.
Q4: Display the details of faculty members who can handle course ora.
Q5: Display the details of batches that are taken by faculty with qualification MS or the course fee is more
than 5000.
Q6: Display the details of the students who belong to batches that are taken by faculty with qualification
MS.
Q7: Display the details of payments made by students of the batch that started on 12-jul-2001.
Q8: Display the details of the batches that have taken maximum duration among the batches of the same
course.
Q9: Get the details of course that has highest course fee.
Q10: Get the details of students who have made a payment in the last month but no in the current month.
Q11: Display the details of course with first two highest course fee.
Q12: Display the details of batches where duration (ENDDATE-STDATE) is more than the average
duration of the course.
Q13: Display third highest course fee.
Q14: Display the details of courses with two lowest fees.
EXISTS, Any operators
Q1: Display details of courses for which at least one batch started in this month.
Q2: Display the details of courses for which no batch has yes started.
Q3: Display name of the courses where FEE is more than FEE of any course with DURATION 25?
Views
1) Create a view that takes everything from COURSES table except FEE column.
2) Create a view called coursecount which consists of course, batchcount (no of batches for that
course), last date ( starting date of the last batch).
3) Display the courses for which we have started more than one batch so far using coursecount view.
4) Create a view called oraclebtaches which consists of details of only oracle batches.
5) Update enddate of batch b7 to sysdate by using view.
6) Delete the batch b1 using view.
7) Create a view months_payments which consists of each student payment details like rollno, name,
dp, amount.
8) Update amount paid by rollno1 to 4500 and truncate dp to ’12-sep-2019’.
9) Update name of the student bearing rollno 1 to Kotch George.

PL/SQL Programs

1) Write a PL/SQL program that uses a nested loop to find the prime numbers between 1 to n.
2) Write a PL/SQL block to change the course fee of VBNET with greatest of average course fee of all
courses and Oracle course fee.
3) Write a PL/SQL program that will update course fee of Java according to the given table.

No. of students Percentage of change


>100 Increase by 20
>50 Increase by 15
>10 Increase by 5
<=10 Decrease by 3

4) Write a PL/SQL program that prints length of each student name using while loop.
5) Write a PL/SQL program that displays missing roll numbers ( which are not in STUDENTS table)
between lowest available rollno and largest available rollno in STUDENTS table using FOR loop.
6) Write a PL/SQL stored function that takes roll number of the student and return the amount yet to be
paid by the student.
7) Write a PL/SQL block to increase the fee of the courses which contains at least 3 students by 10%.
8) Write a PL/SQL cursor to display the name and qualification of the faculty who are teaching the
course called ‘Oracle Database’.
9) Write a PL/SQL cursor to test whether the specified batchcode is present or not.
10) Write a PL/SQL cursor to display the batch details having third place in payments.
11) Write a stored procedure that takes course code and returns the student name who joined first and
last in that course.
12) Create a package with two functions as given below along with exception handling mechanisms:
i) Change the fee of a given course with average of all course plus 10% that course.
ii) Return the faculty name who teaches the batch in which highest payment has been made.
13) Create an user defined exception that will be raised when there are no students in any batch of given
course.
14) Write a PL/SQL block which pays the remaining amount of a given student.
15) Write a PL/SQL block that prints reverse of the given number.
16) Write PL/SQL program to handle NO_DATA_FOUND exception.

Potrebbero piacerti anche