CPS3740 Spring 2017 Homework Na a1 Page 1 of 1 Dr Huang Due
Solution
Initially please understand the requirement .Here are the meanings of the symbolic representation
SELECT -> (sigma)
PROJECT -> (pi)
PRODUCT -> ×(times)
JOIN -> |×| (bow-tie)
UNION -> (cup)
INTERSECTION -> (cap)
DIFFERENCE -> - (minus)
RENAME -> (rho)
1.
The question is about selecting the hotelNo from the table Room where column \'price\' value is greater than 40.
Please replace xxxx with ur/user emailID
create or replace view vHW1_1_xxxx as select hotelNo from dreamhome.Room where price >40;
2.It all about pulling the hotelname by performing join operation where the price of room are less than 60
create or replace view vHW1_2_xxxx as select h.hotelName from dreamhome.Hotel h,dreamhome.Room r where h.hotelNo=r.hotelNo and r.price<60;
3.For this we need to have the schema definition,i.e the table and the respective columns present in the tables,so that we can pull the required columns based on conditions and joins to be made.
The query will be something like:
create or replace view vHW1_3_xxxx as select name,address from dreamhome.Guests where <location column similar which will be mentioned in the table def of Guests> location=\'London\' order by name;
similary with remainin also.
9. we are creating keys using constraint keyword and referencing the table in CSP3740 schema zipcode table
create table dreamhome.Customers_xxxx(id number(10) NOT NULL,name varchar(50) NOT NULL,balance number(8,2) NOT NULL,zipcode varchar(10) NOT NULL,CONSTRAINT id_pk PRIMARY KEY (id),CONSTRAINT fk_zipcode
FOREIGN KEY (zipcode)
REFERENCES CSP3740.Zipcode(zipcode);
10.Inserting values ,we have to make sure the zipcodes ae present in the CSP3740.Zipcode table. and ID value should be uique as primary key it will not allow duplicates.
insert into dreamhome.Customers_xxxx(10,\'xxxx\',30000,\'NY21D\');
insert into dreamhome.Customers_xxxx(20,\'xxxx1\',60000,\'NY31D\');
insert into dreamhome.Customers_xxxx(30,\'xxxx2\',30000,\'NY21D\');
insert into dreamhome.Customers_xxxx(40,\'xx2x\',30000,\'NY41D\');
