Lab - 13
Lab - 13
Class: BESE-14AB
Submitted By :
Name: Muhammad Arslan
Class: BESE-14B
CMS I’d: 465428
1. Create a view named v1 which has the name of faculty members who do not teach any
course.
Query:
CREATE OR REPLACE VIEW v1 AS
SELECT f.fname
FROM faculty f
left join Class c on f.fid=c.fid
WHERE c.fid is null;
Output:
Query:
Output:
Query:
Output:
Query:
5. Notice the changes in views which are based on student relation. Comment what happens to
view data if the base table is modified.
The data in views will change automatically if the underlying base table data (rows)
changes, such as inserting, updating, or deleting. However, if the table structure (columns)
changes, the view will not update unless its definition is explicitly modified.
6. Alter view v2 based on the definition: It has the names of all juniors (Level = JR) who are
enrolled in a class taught by ‘Ivana Teach’.
Query:
CREATE OR REPLACE VIEW v2 AS
SELECT s.sname
FROM Student s
JOIN Enrolled e ON s.snum = e.snum
JOIN Class c ON e.cname = c.cname
JOIN Faculty f ON c.fid = f.fid
WHERE f.fname = 'Ivana Teach' and s.level='JR';
Output:
Query:
Output:
Query:
CREATE VIEW john_williams_classes AS
SELECT c.cname
FROM Class c
JOIN Faculty f ON c.fid = f.fid
WHERE f.fname = 'John Williams' AND f.dept_id = 68;
Output:
Output:
Query:
Output:
Output: