Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can some one help me with sql i have to get 7 query with relational algebra expressions 1-List the name and ID of customers who

can some one help me with sql

i have to get 7 query with relational algebra expressions

1-List the name and ID of customers who made a sales transaction on 2/1/2011.

2-List the customer name and store zipcode of all female customers who made a sales transaction at a store in the region named 'Chicagoland'.

3-List the customer name and customer zipcode of all female customers who bought a product named "Zzz Bag".

4-List the customer name and customer zipcode of all customers who did not buy any items from store S2.

5-List the total number of products that cost less than $100.

6-List the vendor name and the cost of the product with the lowest cost in category CP that is produced by each vendor. Use a natural join when the attributes have the same name.

7-List the region name, store id and store zip for all regions. Include all regions, even those regions without any stores.

*********************************************************************************************

database :

CREATE TABLE vendor ( vid CHAR(2) NOT NULL, vname VARCHAR(25) NOT NULL, PRIMARY KEY (vid) );

CREATE TABLE category ( catid CHAR(2) NOT NULL, catname VARCHAR(25) NOT NULL, PRIMARY KEY (catid) );

CREATE TABLE product ( pid CHAR(3) NOT NULL, pname VARCHAR(25) NOT NULL, price NUMERIC (7,2) NOT NULL, vid CHAR(2) NOT NULL, categoryid CHAR(2) NOT NULL, PRIMARY KEY (pid));

CREATE TABLE region ( rid CHAR NOT NULL, rname VARCHAR(25) NOT NULL, PRIMARY KEY (rid) );

CREATE TABLE store ( sid VARCHAR(3) NOT NULL, szip CHAR(5) NOT NULL, rid CHAR NOT NULL, PRIMARY KEY (sid));

CREATE TABLE customer ( cid CHAR(7) NOT NULL, cname VARCHAR(15) NOT NULL, czip CHAR(5) NOT NULL, gender CHAR(1) NOT NULL, PRIMARY KEY (cid) );

CREATE TABLE salestrans ( tid VARCHAR(8) NOT NULL, custid CHAR(7) NOT NULL, storeid VARCHAR(3) NOT NULL, sdate VARCHAR(10) NOT NULL, PRIMARY KEY (tid));

CREATE TABLE soldvia ( prodid CHAR(3) NOT NULL, transid VARCHAR(8) NOT NULL, numitems INT NOT NULL, PRIMARY KEY (prodid, transid));

INSERT INTO vendor VALUES ('PG','Pacifica Gear'); INSERT INTO vendor VALUES ('MK','Mountain King');

INSERT INTO category VALUES ('CP','Camping'); INSERT INTO category VALUES ('FW','Footwear');

INSERT INTO product VALUES ('1X1','Zzz Bag',100,'PG','CP'); INSERT INTO product VALUES ('2X2','Easy Boot',70,'MK','FW'); INSERT INTO product VALUES ('3X3','Cosy Sock',15,'MK','FW'); INSERT INTO product VALUES ('4X4','Dura Boot',90,'PG','FW'); INSERT INTO product VALUES ('5X5','Tiny Tent',150,'MK','CP'); INSERT INTO product VALUES ('6X6','Biggy Tent',250,'MK','CP'); INSERT INTO product VALUES ('7X7','Comfy Pad',50,'PG','CP'); INSERT INTO product VALUES ('8X8','Turkey Jerky',2,'PG','CP');

INSERT INTO region VALUES ('C','Chicagoland'); INSERT INTO region VALUES ('T','Tristate'); INSERT INTO region VALUES ('D','Downstate'); INSERT INTO region VALUES ('O','OutOfstate');

INSERT INTO store VALUES ('S1','60600','C'); INSERT INTO store VALUES ('S2','60605','C'); INSERT INTO store VALUES ('S3','35400','T');

INSERT INTO customer VALUES ('1-2-333','Tina','60137', 'F'); INSERT INTO customer VALUES ('2-3-444','Tony','60611', 'M'); INSERT INTO customer VALUES ('4-5-666','Pam ','35401', 'F');

INSERT INTO salestrans VALUES ('T111','1-2-333','S1','1/1/2011'); INSERT INTO salestrans VALUES ('T222','2-3-444','S2', '1/1/2011'); INSERT INTO salestrans VALUES ('T333','1-2-333','S3', '2/1/2011'); INSERT INTO salestrans VALUES ('T444','4-5-666','S3', '2/1/2011'); INSERT INTO salestrans VALUES ('T555','2-3-444','S3', '2/1/2011');

INSERT INTO soldvia VALUES ('1X1','T111',1); INSERT INTO soldvia VALUES ('2X2','T222',1); INSERT INTO soldvia VALUES ('3X3','T333',5); INSERT INTO soldvia VALUES ('1X1','T333',1); INSERT INTO soldvia VALUES ('4X4','T444',1); INSERT INTO soldvia VALUES ('2X2','T444',2); INSERT INTO soldvia VALUES ('4X4','T555',4); INSERT INTO soldvia VALUES ('5X5','T555',2); INSERT INTO soldvia VALUES ('6X6','T555',1);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

3. Discuss the process of behavior modeling training.

Answered: 1 week ago