Question: Build a database using the given SQL queries and provide the SQL queries for the following questions: Questions: (provide SQL queries as answers) 1) join
Build a database using the given SQL queries and provide the SQL queries for the following questions:
Questions: (provide SQL queries as answers)
1) join
Get all combinations of Supplier and Part information such that Supplier and Part are located in the same city
2) join condition
Get all combinations of Suppliers and Part information such that the Supplier and Part are located in the same City and the Supplier Rating is less than 30.
Database:
drop table S; drop table P; drop table SP; create table S( sid Char(2) not null primary key, sname Char(4) not null, rating Int not null, city Char(4) not null ); insert into S values ('s1', 'SSSS', 20, 'Tucs'), ('s2', 'JJJJ', 10, 'Phox'), ('s3', 'BBBB', 30, 'Phox'), ('s4', 'CCCC', 20, 'Tucs'), ('s5', 'AAAA', 30, 'Flag') ; create table P( pid Char(2) not null primary key, pname Char(4) not null, weight Int not null, city Char(4) not null ); insert into P values ('p1', 'Nut', 12, 'Tucs'), ('p2', 'Bolt', 17, 'Phox'), ('p3', 'Scrw', 17, 'Casa'), ('p4', 'Scrw', 14, 'Tucs'), ('p5', 'Cam', 12, 'Phox'), ('p6', 'Cog', 19, 'Tucs') ; create table SP( sid Char(2) not null, pid Char(2) not null, qty Int not null, Primary Key (sid, pid) ); insert into SP values ('S1', 'P1', 300), ('S1', 'P2', 200), ('S1', 'P3', 400), ('S1', 'P4', 200), ('S1', 'P5', 100), ('S1', 'P6', 100), ('S2', 'P1', 300), ('S2', 'P2', 400), ('S3', 'P2', 200), ('S4', 'P2', 200), ('S4', 'P4', 300), ('S4', 'P5', 400) ;
Step by Step Solution
There are 3 Steps involved in it
To provide SQL queries for the problems stated lets first understand the schema briefly S Table Supp... View full answer
Get step-by-step solutions from verified subject matter experts
