0% found this document useful (0 votes)
178 views16 pages

Dbms Assignment HW

The document describes the structure of 10 tables to store student, course, schedule, and grade information for a university database. It includes the table names, column names and data types for tables to store information about students, departments, faculty, courses, class schedules, class locations, classes, and student grades. DDL commands like CREATE TABLE are provided to define the structure of each table.

Uploaded by

Devashish Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
178 views16 pages

Dbms Assignment HW

The document describes the structure of 10 tables to store student, course, schedule, and grade information for a university database. It includes the table names, column names and data types for tables to store information about students, departments, faculty, courses, class schedules, class locations, classes, and student grades. DDL commands like CREATE TABLE are provided to define the structure of each table.

Uploaded by

Devashish Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Assignment – 1

Lab Exercises
DDL COMMANDS CREATING A TABLE LAB-01
(1) Student Information Table: student dept_id varchar2(3) Foreignkey
Student_id varchar2(20) designation varchar2(20)
Last_name varchar2(25) d_o_j date
First_name varchar2(20) Last_Name varchar2(25)
Dob varchar2(20) First_Name varchar2(200)
Address varchar2(50) Telephone number(8)
City varchar2(20) mobile number(10)
State varchar2(20) Email varchar2(30)
ZipCode number(6) (4) Course Information Table: courses
Telephone number(8) Course_Id varchar2(10)
Mobile number(10) dept_Id varchar2(3) foreignkey
Email varchar2(100) Title varchar2(30)
Fees number(6)
primarykey (course_id, department_id)
create table stud_info(Student_id varchar2(20), Last_name
varchar2(25),First_name varchar2(20), Dob varchar2(20),
create table course(Course_Id varchar2(5),Department_Id
Address varchar2(300), City varchar2(20),State
varchar2(20) references depart_info(department_id),Title
varchar2(2),
char(60),Description varchar2(200), Additional_fees number
ZipCode varchar2(9),Telephone varchar2(10), Fax primary key);
varchar2(10),
Email varchar2(100));
(5) Schedule Type Header Table: schedule_type
Schedule_Id varchar2(20)
(2) Department Information Table: deptt Schedule_Description varchar2(50)
dept_id varchar2(3) primarykey
dept_name varchar2(25)
create table sche_head(Schedule_Id varchar2(20) primary
key,Schedule_Description varchar2(200));
create table depart_info(Department_Id
varchar2(20)primary key, Department_Name varchar2(25));
(6) Schedule Type Details: schedule_detail
(3) Faculty's Information Table: faculty Schedule_Id varchar2(20)
Faculty_id varchar2(20) primarykey Day number(1)
Starting_Time date Grade in ('A','A+','A-','B','B+','B-',
Duration number 'C','C+',C-','D','D+','D-','F','F+','F-')
Date_Grade_Assigned date
create table sche_type(Schedule_Id varchar2(20),Day
number,Starting_Time date,Duration number); create table stud_sche(Student_Id varchar2(20), Class_Id
varchar2(20),Grade varchar2(2) check (Grade
(7) Class Location Information: class_loc in('A','A+','A-','B','B+','B-','C','C+','C-','D','D+','D-','F','F
Class_Building varchar2(25) +','F-')), Date_Grade_Assigned date);
Class_Room varchar2(25)
Seating_Capacity varchar2(2) (10) Describe the structure of the following tables.
1. Student information table
Name Null? Type
create table class_loc(Class_Building varchar2(25), ------------------------------- -------- ----
Class_Room varchar2(25), Seating_Capacity varchar2(2)); STUDENT_ID VARCHAR2(20)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(20)
(8) Class Table: class_table DOB VARCHAR2(20)
Class_Id varchar2(20) primarykey ADDRESS VARCHAR2(300)
Schedule_Id varchar2(20) CITY VARCHAR2(20)
Class_Building varchar2(25) STATE VARCHAR2(2)
Class_Room varchar2(25) ZIPCODE VARCHAR2(9)
Course_Id varchar2(5) TELEPHONE VARCHAR2(10)
Department_Id varchar2(20) foreign key FAX VARCHAR2(10)
Dept_info(Department_id) EMAIL VARCHAR2(100)
Faculty_Id varchar2(20) Faculty(Faculty_id)
Semester varchar2(6)
School_Year date 2. Department information table
Name Null? Type
create table class(Class_Id varchar2(20) primary key, ------------------------------- -------- ----
Schedule_Id varchar2(20),Class_Building varchar2(25), DEPARTMENT_ID NOT NULL
Class_Room varchar2(25),Course_Id varchar2(5), VARCHAR2(20)
Department_Id varchar2(20),Instructor_Id varchar2(20) DEPARTMENT_NAME
references Inst(Instructor_Id),Semester varchar2(6), VARCHAR2(25)
School_Year date)
3. Faculty's Information Table
(9) Student Grade Information Table: grade_info
Student_Id varchar2(20) 4. Course Information Table
Class_Id varchar2(20) Name Null? Type
Grade varchar2(2)Check ------------------------------- -------- ----
COURSE_ID VARCHAR2(5) 8. Class table
DEPARTMENT_ID VARCHAR2(20)
TITLE CHAR(60) desc class
DESCRIPTION VARCHAR2(200) Name Null? Type
ADDITIONAL_FEES NOT NULL NUMBER ------------------------------- -------- ----
CLASS_ID NOT NULL VARCHAR2(20)
SCHEDULE_ID VARCHAR2(20)
5. Schedule Type Header Table CLASS_BUILDING VARCHAR2(25)
Name Null? Type ------------------------------- -------- ---- CLASS_ROOM VARCHAR2(25)
SCHEDULE_ID NOT NULL VARCHAR2(20) COURSE_ID VARCHAR2(5)
SCHEDULE_DESCRIPTION VARCHAR2(200) DEPARTMENT_ID VARCHAR2(20)
INSTRUCTOR_ID VARCHAR2(20)
SEMESTER VARCHAR2(6)
SCHOOL_YEAR DATE
6. Schedule Type Details
Name Null? Type 9. Student Grade Information Table
------------------------------- -------- ----
SCHEDULE_ID VARCHAR2(20) desc stud_sche
DAY NUMBER Name Null? Type
STARTING_TIME DATE ------------------------------- -------- ----
DURATION NUMBER STUDENT_ID VARCHAR2(20)
CLASS_ID VARCHAR2(20)
7. Class Location Information GRADE VARCHAR2(2)
Name Null? Type ------------------------------- -------- ---- DATE_GRADE_ASSIGNED DATE
CLASS_BUILDING VARCHAR2(25)
CLASS_ROOM VARCHAR2(25)
SEATING_CAPACITY VARCHAR2(2)

DDL Commands (ALTER) (Any 5)


Alter the Table with the following requirements.
(Hint: Use Alter Table Command)  Alter the datatype of Dob to Date
alter table stud_info modify(dob date);
(1) Alter the student table to make the following changes:
 Add a new column SEX which is of char datatype.  Add a primary key constraint for the Student Id.
alter table stud_info add(sex char(6)); alter table stud_info add primary key(student_id);
 Alter the column size of First_Name to 25.
alter table stud_info modify(first_name varchar2(25));
(2) Alter the new column Position in Faculty table which datatype
varchar2 and size 25 with a check constraint which checks for (5) Alter the Class Table to make the following changes:
‘ASSISTANT PROFESSOR','ASSOCIATE PROFESSOR',  Add a foreign key for the column Schdule_Id which refers
'PROFESSOR'. schedule(Schedule_Id)
alter table class add foreign key(schedule_id) references
alter table inst add(position varchar2(25)check(position
sche_head(schedule_id);
in('ASSISTANT PROFESSOR','ASSOCIATE
PROFESSOR','PROFESSOR')));
 Add a foreign key for the column Department_Id which refers
Department(Department_Id)
(3) Alter the Schedule Type Header Table to make the following alter table class add foreign key(department_id) references
changes: depart_info(department_id);
1. Reduce the size of the schedule description to 100.
alter table sche_head modify(schedule_description varchar2(100));  Add a foreign key for the column Course_Id which refers
Course(Course_Id).
2. Add a primary key for Schedule_Id. alter table class add foreign key(course_id) references
alter table sche_head add primary key(schedule_id); course(course_id);

(4) Alter the Schedule Type Details to make the following changes:
 Add a composite primary key to the columns Schedule_id, day. (6) Add the new column hod the data type is varchar2(25) into
alter table sche_type add primary key(day); depart_info.
alter table depart_info add(hod varchar2(25));
 Add a Foreign key to the column Schedule_id which refers
schedule_id (Schedule Type Header). (7) Alter table student add column dept_id set as foreign key
alter table sche_type add foreign key(schedule_id) references alter table student add foreign key(department_id)
sche_head(schedule_id); references depart_info(department_id);

DDL COMMANDS Adding Constraints (Any 5)


1. Enable the primary key student_id student table.
Alter table stud_info enable stud_pk;

2. Disable the foreign key schedule_id in schedule_type_details table.


Alter table sche_type disable sche_pk;

3. Enable the foreign key fk_class_schedule_id in class table.


Alter table sche_type enable sche_fk;
4. Drop the primary key student_id in student table.
Alter table stud_sche enable class_fk;

5. Drop the foreign key schedule_id in schedule_type_details.


Alter table course drop pk_course;
DML COMMANDS: (Any 5)
1. Insert Records into the following tables. (3) Set save points after every ten insertion.
a. Department Information Table. savepoint s1;
insert into depart_info values('&department_id',
'&department_name','&hod');
Enter value for department_id: d01 (4) Roll back to the second save point.
old 1: insert into depart_info values('&department_id', rollback;
new 1: insert into depart_info values('d01',
Enter value for department_name: computer (5) Set save point del.
Enter value for hod: vasu
savepoint del;
old 2: '&department_name','&hod')
new 2: 'computer','vasu')
(7) Set save point ins.
savepoint ins;

Using SELECT COMMAND (Any 3)


1. Display the Student Id and the Firstname from the Student table Select Firstname, dob from stud_info where Firstname like
who doesn't have a telephone and an email. ‘___a%’;
Select student_id, Firstname from stud_info where telephone is
null and email is null; 3. Display Students Firstname, Dob whose Birthday falls today.
Select firstname,dob from stud_info where dob=15-10-2021
2. Display Students Firstname, Dob whose Firstname contains 'A' in
the Fourth position.

Using SELECT COMMAND (date function) (Any 3)


1. Display the first day of a given year.
Select round(sysdate,’day’) from dual;
2. Display the no of months of the students since their birth.
Select months_between(sysdate,dob) from stud_info;

3. Display the Students Firstname, Dob in the format "DD/MONTH/YYYY".


. Select first_name,to_char(dob,’dd/month/yyyy’) from stud_info;

Using SELECT COMMAND (Any 3)


1. Display Students Id from the Student table whose Lastnames are unique.
Select distinct(last_name) from stud_info group by last_name;

2. Display Course Id, Department Id from the Course table where the fees is the least.
Select Course Id, Department Id from course where additional_fees = (select min(additional_fees) from course);

3. Display the Course Id, fees from the course table with the fees in the format '$999.99'.
Select Course Id, to_char(Additional_fees,$999.99) from course;

DML COMMAND (Update) (Any 3)


1. Update all information’s from the Student table whose lastname is null to a last name of 'Nil'.
Update stud_info set last_name = ‘nil’ where last_name is null;

2. Update Students Last name whose city is Madras to ‘Chennai'.


Update stud_info set last_name = ‘madrasi’ where city = ‘chennai’;

3. Update Students Last Name whose state starts with the letter 'T' to a value of 'TTT'.
Update stud_info set last_name = ‘TTT’ where state like ‘T%’;

DML COMMAND (Delete Function) (Any 5)


1. Delete all information’s from the Student table whose lastname is Delete from stud_info where Last_name is null;
null.
2. Delete the information from Student table that doesn't have a
telephone and an email. 4. Delete Students information whose city is Chennai.
Delete from stud_info where telephone is null and email is null; Delete from stud_info where city =’chennai’;

3. Delete all information from the Student table where the Students 5. Delete Students information whose Firstname contains 'A' in the
Firstname is of only ten characters. Fourth position.
. Delete from stud_info where length(first_name) = 10; Delete from stud_info where first_name like ‘___a%’;

DCL Commands (Rollback/ Savepoint/Commit) (Any 5)


1. Rename the student information table as student. Rollback;
Rename stud_info to student;
4. Disable the primary key constraint of facultys information table.
2. Create a savepoint s1. Alter table inst disable inst_pk;
savepoint s1;
5. Truncate the employee table.
3. Rollback to savepoint s1. Truncate employee;

Using SQL functions like AVG, MAX CASE statements (Any 5)

1. Find the first name of the ‘A’ grade students. Select count (*) from employee where basic >= 2000;
select first_name from stu_info where student_id =(select
student_id from stud_sche where grade = ‘A’); 4. Count the number of student whose state is TN and august month
babies.
2. Count the total number of students in student information table. Select count (*) from stud_info where state =’TN’ and
Select count(*) from stud_info; to_char(dob,’month’)=’August’;
.
3. Count the number of employee having basic greater than or equal 5. Display the name of the faculty in upper case.
to 2000. Select upper (concat(first_name,Last_name)) from inst;

Creating a View synonym and index (Any 5)


1. Create a view named student from student information and f. Total fees (i.e. units *250 + fees)
department information tables that contains only the following Create view course_view as select
columns student_id, first name, last name and department_id. Course_id,Department_id,
Create view student as select student_id,first_name,last_name, Title,Description,Additional_fees, (units *250 +
department_id from stud_info ,depart_info ; additional fees) as Total_fees from course;

6. Replace the view class_summary by removing the column title


2. Create a table dummy with two columns( name, id). from the class table.
Create table dummy(name varchar2(10),id number(8)); Create view class_summary as select * from class_view;

3. Create a view course_view from the course table with the 7. Delete the rows from the course_view where deparment id is null
following fields. and fees > 100 and total fees less than 500.
a. Course id. Delete from class_view where department_id is null and
b. Department id additional_fees > 100 and total_fees < 500;
c. Title
d. Description
e. fees

More Examples on Index (Any 3)


1. Create an index stud_last on the student table (Lastname).
Create index stud_last on stud_info(last_name);

2. Create an unique index dept_name on the department table(department name).


Create index dept_name on depart_info(department_id);

3. Drop index stud_last.


Drop index stud_last;

ASSIGNMENT – 2
Cursors
Note: use the cursor attributes % found, % notfound, % rowcount, % isopen
1. Write PL/SQL block to decrease the fees in the Course table to 5%.
declare cursor c2 is
select additional_fees from course;
a course additional_fees%type; begin open c2;
loop fetch c2 into a; exit when c2%notfound;
update course set additional_fees = a-a * .05;
end loop; close c2;
End;

2. Write a PL/SQL block to display the schedule_id, schedule_description, day, starting_time, and duration from the schedule_type header,
schedule_type details tables.

Database Triggers. (Any 4)


(1) Write a database trigger before insert for each row on the course table not allowing transactions on Sundays and Saturdays.
create or replace trigger t1 before insert on course for each row begin if not(to_char(sysdate,’month’)=’sunday’ or
to_char(sysdate,’month’)=’saturday’) then dbms_output.put_line(‘inserting operation’); else dbms_output.put_line(‘insertion not allowed’);
end if; end;

(2) Write a database trigger after update for each row giving the date and the day on which the update is performed on the class table.
create or replace trigger t2 after update of date on class for each row begin dbms_output.put_line(‘updating operation’); end;

(3) Write a database trigger before delete for each row not allowing deletion and giving message on the department table.
create or replace trigger t3 before delete on depart_info for each row begin dbms_output.put_line(‘do you want to delete’); end;

(5) Write a database trigger before insert/delete/update for each row not allowing any of these operations on the table student on Mondays.
Wednesdays, Sundays.
Create or replace trigger t5 before insert/update/delete on stud_info for each row begin if (to_char(sysdate,’month’)=’monday’ or
to_char(sysdate,’month’)=’wednesday’ or to_char(sysdate,’month’)=’sunday’) then dbms_output.put_line(‘trigger operation’); else
dbms_output.put_line(‘insertion not allowed’); end if; end;
PL/SQL programming (Any 4)

1. Write PL/SQL block to increase the salary by 10% if the salary is > 2500 and > 3000.
begin if salary > 2500 and salary < 3000 then salary = salary + 10 /100; end if; end;

2. Write PL/SQL block to decrease the salary by 13% if the salary is >3000 and < 5000.
begin if salary > 3000 and salary < 5000 then salary = salary + 13 / 100; end if; end;

1. Write PL/SQL block to display the male employees details.


declare s emp%rowtype; begin select * into s from emp where sex =’male’; dbms_output.put_line(s); end;

2. Write PL/SQL block to display the total salary (I,e.Salary +Comm) of each employee whose comm. Is not null.
declare t number(9,2); begin select (salary + comm) as total_salary from emp where comm is not null; end;

Sub programs & packages

1. Create a procedure that takes an argument (description) and deletes the row from the course table.
create or replace procedure dele(d in varchar2(200))is begin delete from class where description = d; end; exec dele(‘Information
Technology’);

2. Create a procedure that displays the faculty details, class details and the student details of a particular student which the user inputs.
create or replace procedure disp(s in varchar2(20))is begin select c.class_id,c.class_building,c.class_room, s.student_id,s.first_name,s.dob,
i.instructor_id, i.first_name from class c,stud_info s,inst i; end;

Creating a relation from existing tables


(1) Create master detail relations for student and student grade table. Student information table is the master table and student grade table is the detail
table it gives the grade detail of the course.
(2) Create a master detail relation for schedule header and schedule type tables.

Assignment – III

ER – Diagram Assignment
1. Draw an ER diagram to capture the requirements as stated below:

A database is needed to capture information pertaining to the running of various clubs by the recreation cell of an institution.
• Details such as name, date of birth, gender are needed for each member.
• Club details are needed such as the activity type (oratorical, music, dance, instrumental music etc) and contact phone number.
• Team details required to include team name and the days on which the team practices.
• Tutor details such as tutor name, address and telephone number are also needed, along with details of the skill each tutor is qualified in.
• Rules governing the involvement of members and tutors in the teams and clubs are as follows:

o Members may head only one team and every team has to have a head. Tutors teach at least one team and every team has at least one tutor.
o Every member must belong to at least one team and each team has a number of members.
o Every team must belong to a club and clubs must have at least one team.
o Every club has a member who is the president but a member may only be president of one club.

Draw the ER Diagram for the above requirement. Map the ER diagram to the Relational Model. Create tables identified and insert five tuples
in each of the tables created. The students are required to carefully take care of the constraints on each of the table.

2. Draw the ER-Diagram For Given Schema

DEPT: DEPTNO (NOT NULL, NUMBER (2)), DNAME (VARCHAR2 (14)), LOC (VARCHAR2 (13)

EMP:EMPNO (NOT NULL, NUMBER (4)), ENAME (VARCHAR2 (10)), JOB (VARCHAR2 (9)), MGR (NUMBER (4)), HIREDATE
(DATE), SAL (NUMBER (7, 2)), COMM (NUMBER (7, 2)), DEPTNO (NUMBER (2))
MGR is the empno of the employee whom the employee reports to. DEPTNO is a foreign
SQL ASSIGNMENT IV
EMPLOYEE DATABASE – I
Table
Dept (dept_id,dept_name,manager_id,loc_id)
Emp (emp_id,first_name,last_name,email,phone,hire_date,job_id,salary,commission_pct, manager_id,dept_id)
This assignment has two sets A and B. Both have same tables

SET – A OF EMPLOYEE DATABASE – II


Queries
1. The HR department needs a query to display all unique job codes from the EMPLOYEES table.
(HINT: like account, manager, asst, president, VP, clerk etc)
2. Thes for its report on employees. Name the column headings Emp #, Employee, Job, and Hire Date, respectively.
3. Change the salary to $1,000 for all employees who have a salary less than $900.
4. The HR department has requested a report of all employees and their job IDs. Display the last name concatenated with the job ID (separated by a
comma and space) and name the column Employee and Title.
5. Due to budget issues, the HR department needs a report that displays the last name and salary of employees who earn more than $12,000.
6. The HR department wants to determine the names of all employees who were hired after Davies. Create a query to display the name and hire date
of any employee hired after employee Davies.
7. Create a report that displays the last name and department number for employee number 176.
8. The HR departments needs to find high-salary and low-salary employees. display the last name and salary for any employee whose salary is not
in the range of $5,000 to $12,000.
9. Produce a list of jobs for departments 10, 50, and 20, in that order. Display job ID and department ID using set operators.
10. Create a report to display the last name, job ID, and start date for the employees with the last names of Matos and Taylor. Order the query in
ascending order by start date.
11. The HR department needs a report to display the employee number, last name, salary, and salary increased by 15.5% (expressed as a whole
number) for each employee. Label the column New Salary.
SET – B OF EMPLOYEE DATABASE – II

1. Write a query that displays the last name (with the first letter uppercase and all other letters lowercase) and the length of the last name for all
employees whose name starts with the letters J, A, or M. Give each column an appropriate label. Sort the results by the employees’ last names.
2. Create a query to display the last name and salary for all employees. Format the salary to be 15 characters long, left-padded with the $ symbol.
Label the column SALARY.
3. Find the highest, lowest, sum, and average salary of all employees for each job type. Label the columns Maximum, Minimum, Sum, and Average,
respectively. Round your results to the nearest whole number.
4. The HR department needs a report on job grades and salaries. To familiarize yourself with the JOB_GRADES table, first show the structure of
the JOB_GRADES table. Then create a query that displays the name, job, department name, salary, and grade for all employees.
5. Create a report that displays the employee number, last name, and salary of all employees who earn more than the average salary. Sort the results
in order of ascending salary.
6. The HR department needs a report that displays the last name, department number, and job ID of all employees whose department location ID is
1700.
7. The HR department needs a list of department IDs for departments that do not contain the job ID ST_CLERK. Use set operators to create this
report.
8. Change the last name of employee 3 to Drexler.
9. The staff in the HR department wants to hide some of the data in the EMPLOYEES table. They want a view called EMPLOYEES_VU based on
the employee numbers, employee names, and department numbers from the EMPLOYEES table. They want the heading for the employee name
to be EMPLOYEE.
10. The HR department needs a report that displays the last name and hire date for all employees who were hired in 1994.
11. Department 50 needs access to its employee data. Create a view named DEPT50 that contains the employee numbers, employee last names, and
department numbers for all employees in department 50. You have been asked to label the view columns EMPNO, EMPLOYEE, and DEPTNO.

DATABASE – II
Consider the following three tables – SAILORS, RESERVES and BOATS

having the following attributes SAILORS (Salid, Salname, Rating, Age)


RESERVES (Salid, Boatid, Day)
BOATS (Boatid, Boat-name, Color) Use the above schema and solve the queries using SQL
i) Find the name of sailors who reserved green boat.
ii) Find the colors of boats reserved by “Ramesh”
iii) Find the names of sailors who have reserved a red or green boat.
iv) Find the Sailid’s of sailors with age over 20 who have not registered a red boat.
DATABASE – III
Consider the following relational database schema:

STUDENT ( Student_id, Sname, Major, GPA) FACULTY (Faculty_id, fname, dept, designation, salary) COURSE (Course_id, Cname, Faculty_id)
ENROL (Course_id, Student_id, grade) Use the above schema and solve the queries using SQL
i) List the names of all students enrolled for the courses “CS-53”
ii) List the names of students enrolled for the courses “CS-53” and have received “A” grade.
iii) List all the departments having an average salary of above Rs20,000.
iv) Give a 15% raise to salary of all faculty.
v) List the names of all faculty members beginning with “R” and ending with letter “U”.

DATABASE – IV
Consider the following relational database schema:

CUSTOMER (CUST_ID, CUST_NAME, ANNUAL_REVENUE, CUST_TYPE) CUST_ID must be between 100 and 10,000
ANNUAL_REVENUE defaults to $20,000 CUST_TYPE must be manufacturer, wholesaler, or retailer SHIPMENT (SHIPMENT_#, CUST_ID,
WEIGHT, TRUCK_#, DESTINATION, SHIP_DATE) Foreign Key: CUST_ID REFERENCES CUSTOMER, on deletion cascade Foreign Key:
TRUCK_# REFERENCES TRUCK, on deletion set to null Foreign Key: DESTINATION REFERENCES CITY, on deletion set to null WEIGHT
must be under 1000 and defaults to 10 TRUCK (TRUCK_#, DRIVER_NAME) CITY (CITY_NAME, POPULATION)
Perform the following queries:
a) What are the names of customers who have sent packages (shipments) to Sioux City?
b) What are the names and populations of cities that have received shipments weighing over 100 pounds?
c) List the cities that have received shipments from customers having over $15 million in annual revenue.

DATABASE – V
Consider the following relational database schema:

CUSTOMER (CUST_ID, CUST_NAME, ANNUAL_REVENUE, CUST_TYPE) CUST_ID must be between 100 and 10,000
ANNUAL_REVENUE defaults to $20,000 CUST_TYPE must be manufacturer, wholesaler, or retailer
SHIPMENT (SHIPMENT_#, CUST_ID, WEIGHT, TRUCK_#, DESTINATION, SHIP_DATE) Foreign Key: CUST_ID REFERENCES
CUSTOMER, on deletion cascade Foreign Key: TRUCK_# REFERENCES TRUCK, on deletion set to null Foreign Key: DESTINATION
REFERENCES CITY, on deletion set to null WEIGHT must be under 1000 and defaults to 10
TRUCK (TRUCK_#, DRIVER_NAME) CITY (CITY_NAME, POPULATION).
Perform the following queries:
a) What are the names of customers who have sent packages (shipments) to Sioux City?
b) What are the names and populations of cities that have received shipments weighing over 100 pounds?
c) List the cities that have received shipments from customers having over $15 million in annual revenue.
Pl/Sql Lab Assignment
Create assignment assuming appropriate tables
1. WAP in PL/SQL for addition of 1 to 100 numbers.

2. WAP in PL/SQL to inverse a number, e.g. 5467 must be inverted to 7645.

3. WAP in PL/SQL for changing th eprice of product ‘p00001’ to 7000 if it’s price is less then 7000 and update this transation by updating the table.

4. Create a view which shows the detail of salesman with his salary. (Salesmanname, salary)

5. Create a trigger on sailors table after updating a row into table.

6. Write the pl/sql program to find division of two numbers and store it in a table?

7. WAP in pl/sql to implement whether the given number is palindrome or not

8. WAP in PL/SQL to write a Cursor to display the list of employee and total salary departmentwise.

9. WAP in PL/SQL to write a Cursor to display the list of employees who are working as Managers or Analystst.

10. Write a Trigger to ensure that Dept table does not contain duplicate of null values in Deptno column.

You might also like