week -03 dbms
week -03 dbms
Table creation
Week-02
Q1. Display the entire course table.
Q2. Display all information about any course with a zero clabfee.
Q3. Display all information about any course which is offered by the
philosophy department.
Q7. Display all information about courses having cname values which
follow “HEDONISM” in alphabetic sequence.
Q8. Display the cno, cname, and cdept values (in that order) for every row
in the course table. 9.
Q13.For each course with a lab fee less than $100, display the academic
department which offers the course and the number of awarded credits.
Query- select name, cdept, cred from minor where clbfee < 100;
Q14. Display the course number and name of every course which has a
lab fee over $100. Include a third column in the result table which shows
“EXPENSIVE” in each row.
Query- select cno,name,’EXPENSIVE’ as status from minor where
clbfee>100;
WEEK -03
Q1. Change the lab fee for the course with course number “19” to $175.
Q3. Delete all rows from the COURSE table which have a course number
greater than 23.
Query=DELETE from minor where cno>13;
Q4. Display the CNAME, CNO, CRED, and CLABFEE columns (in that order)
for every row in the table. Sort the displayed rows by CNO within
CLABFEE. (CLABFEE is the major sort field, and CNO is the minor sort
field).
Q5. Display the CDEPT, CLABFEE, and CNAME values of all three credit
courses. Sort the output result. CDEPT is the first-level sort field
(ascending); CLABFEE is the second-level sort field (descending); and
CNAME is the third-level sort field (ascending).
Q6. Display all information about any three-credit philosophy course which
has a lab fee strictly between $0 and $100.
Query =select * from minor where cred =3 and clbfee>0 and clbfee<100;
Q7. Display all information about every course offered by the philosophy
or theology department.
Q8. Display all information about any course which has a lab fee equal to
$50, $100, $150, or $200.
Q9. Select the CNO, CNAME, and CLABFEE of any course with a lab fee
other than $100.
Query=select cno,name,clbfee from minor where !(clbfee=100);
Q10. Display the name and department identifier of all courses with the
exception of those courses offered by the CIS and PHIL departments.
Q11. Display any information about any theology course which has a zero
lab fee, or any course (regardless of its department and lab fee) which is
worth six credits.
Q13. Display the course number, description, and credits for any course
which is worth two, six, or nine credits.
Q16. Display the course number and lab fee of any course with a lab fee
which is less than $50 or greater than $400.
Q17. Display the department identifier, course name, and lab fee of any
three-credit CIS, THEO or MGT course with a lab fee between, and
including, $50 and $300. Sort the result by course name within
department identifier sequence (ascending).
Q1. Display the information about any course which has a description
beginning with the string“FOR THE”.
Q2. Display all CNAME values which end with the letters “CISM”.
Q4. Display the course number and description of any course with a
period, hyphen, or exclamation mark anywhere in its description.
Query – select cno,c_desc from minor where c_desc like '%!%' or c_desc
like '%-%' or c_desc like '%.%';
Q5. Display the department identifier of any course where the department
identifier ends with “IL”.Do not display duplicate values.
Q6. Display the course name and department identifier of any course
which has the letter “H” present in the second position of its department
identifier and is exactly four characters long.
Query – select name,cdept from minor where cdept like ‘_H__’ and
length(cdept)=4;
Q7. Display the names of courses which have a vowel as the second letter
of their name.
Query - select name from minor where name like '_A%' or name like '_E%'
or name like '_I%' or name like '_O%' or name like '_U%';
Q8. Display the name and description of any course where the description
has “THE” in the fifth, sixth, and seventh positions, and “A” in the tenth
position.
Query - select name from minor where !(name like '_A%' or name like '_E
%' or name like '_I%' or name like '_O%' or name like '_U%');
Q10. Display the course name and description of any course which does
not end with an “E” or an“S”.
Query – select name,c_desc from minor where !(name like '%E' or name
like '%S');
2.) CREATE TABLE Orders ( OrderID INT PRIMARY KEY, OrderNumber INT,
PersonID INT);
Q12. Create a FOREIGN KEY constraint on the PersonID column when the
Orders table is already created.
Q13. Insert at least 5 records into the Person table and 3 records into the
Orders table.
Query –
(1,77895,3),
(2,44678,3),
(3,22456,2),
(4,24562,1);
Q14, Drop the Foreign Key from the Orders table.
Week -05
Q1. Suppose that we are interested in the impact of increasing the lab fee
charges for all CIS courses. What would be the lab fee for each CIS course
if its lab fee were increased by $25? Display each CIS course name
followed by the current lab fee and the adjusted lab fee.
Q3. What would be the lab fee of a theology course if each such course
were charged $10.50 per credit? Display the course number and the
adjusted lab fees of all theology courses.
Q4. What is the average lab fee per credit hour for courses offered by the
CIS department?
Q6. Which CIS courses have an average lab fee per credit hour value
greater than $30?
Q7. What is the average lab fee for all courses described in the course
table?
Q9. What is the sum of all the lab fee values for CIS courses?
Q10. How many theology courses are recorded in the COURSE table?
Q11. Display the average, maximum, and minimum course lab fees for
those CIS courses which have non-zero lab fee.
Query - select avg(clbfee) as avg_clbfee,max(clbfee)as max_clbfee,
min(clbfee) as min_clbfee from minor where cdept="CIS" and clbfee>0;
Q12. 12. Display the variance and standard deviation of all the course lab
fees in the COURSE table.
Q13. Display two values. The first is the sum of all lab fees assuming each
has been increased by $25. The second is the result of adding $25 to the
sum of all the lab fees.
Q14. For each department which offers courses, determine the average
lab fee of all three-credit courses offered by the department. Display the
output in ascending sequence by department identifier.
Q16. For each distinct lab fee value, determine the total number of credits
for courses having this lab fee value. Sort the result by lab fee in
descending order.
Q17. For each department which offers six-credit courses, display the
average lab fee of the six-credit courses.
Q19. For every department, except the theology department, which has
an average lab fee of $100,display its department identifier followed by its
average lab fee.
Q20. Retrieve the average, maximum, and minimum lab fee values by
credit within a department only for those groups which have a maximum
lab fee value greater than zero.
greater than $100 and the department offers less than six courses?