Question: CSE 1 1 1 DATABASE SYSTEMS Lab 9 : Views In this lab session you will learn how to work with SQL views. You will

CSE 111 DATABASE SYSTEMS
Lab 9: Views
In this lab session you will learn how to work with SQL views. You will create views based on queries from
Lab 4 and rewrite the same queries with the views. You will do all these in a Java or Python application,
for which we provide skeleton code (Lab 9.java) and Python (Lab 9.py). While you have the freedom to
choose which programming language you use, you have to completely implement the lab in one of the two
languages.
The tasks you have to implement are the following:
1. Create a view V1(c custkey, c name, c address, c phone, c acctbal, c mktsegment, c comment, c nation,
c region) that appends the country and region name to every customer. Rewrite Q1 from Lab 4 with
view V1.
2. Create a view V2(o orderkey, o custkey, o orderstatus, o totalprice, o orderyear, o orderpriority, o clerk,
o shippriority, o comment) that replaces o orderdate with the year o orderyear and contains all the
other attributes in orders. Rewrite Q2 from Lab 4 with views V1 and V2.
3. Rewrite Q3 from Lab 4 with view V1.
4. Create a view V4(s suppkey, s name, s address, s phone, s acctbal, s comment, s nation, s region) that
appends the country and region name to every supplier. Rewrite Q4 from Lab 4 with view V4.
5. Rewrite Q5 from Lab 4 with view V4.
6. Rewrite Q6 from Lab 4 with views V2.
7. Rewrite Q7 from Lab 4 with views V1 and V2.
8. Rewrite Q8 from Lab 4 with views V2 and V4.
9. Rewrite Q9 from Lab 4 with views V2 and V4.
10. Create a view V10(p type, min discount, max discount) that computes the minimum and maximum
discount for every type of part. Rewrite Q10 from Lab 4 with view V10.
11. Create two views V111(c custkey, c name, c nationkey, c acctbal) and V112(s suppkey, s name, s nationkey,
s acctbal) that contain the customers with negative balance and the suppliers with positive balance,
respectively. Rewrite Q11 from Lab 4 with views V111 and V112.
12. Rewrite Q12 from Lab 4 with view V4.
13. Rewrite Q13 from Lab 4 with views V1 and V4.
14. Rewrite Q14 from Lab 4 with views V1 and V4.
15. Rewrite Q15 from Lab 4 with view V4.
In order to complete the lab you have to perform the following tasks:
1. Write the Java code that implements the required functionality in the corresponding methods in
file Lab 9.java. If you use Python, you edit the file Lab 9.py. This is the only file you have to
edit. Moreover, you have to write code only in the specified methods/functions. There are 21 such
methods/functions overall.
2. For your reference, we provide you the SQL statements for all the queries in Lab 4 in file queries-lab-4.sql.
3. The format of the expected output for every query is available in output/x.out.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!