Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

here is the colum name : answer the question following this. create table customer ( cus_code int, cus_lname varchar(20), cus_fname varchar(20), cus_initial char(1), cus_areacode int,

here is the colum name :

answer the question following this.

create table customer (

cus_code int,

cus_lname varchar(20),

cus_fname varchar(20),

cus_initial char(1),

cus_areacode int,

cus_phone int,

primary key(cus_code));

create table invoice (

inv_number int,

cus_code int,

inv_date date,

primary key(inv_number),

foreign key(cus_code)references customer(cus_code));

create table vendor (

vend_code int,

vend_name varchar(30),

vend_contact varchar(30),

vend_areacode int,

vend_phone int,

primary key(vend_code));

create table product (

prod_code int,

prod_desc varchar(50),

prod_price int,

prod_quant int,

vend_code int,

primary key(prod_code),

foreign key(vend_code)references vendor(vend_code));

create table line (

inv_number int,

prod_code int,

line_units int,

primary key(inv_number, prod_code),

foreign key(inv_number) references invoice(inv_number),

foreign key(prod_code) references product(prod_code));

Write SQL statements to answer the following questions using schema (Customer-Invoice-Line-Product-Vendor).

customer:

10010, Ramas, Alfred, A, 615, 8442573

10011, Dunne, Leona, K, 713, 8941238

10012, Smith, Kathy, W, 615, 8942285

10013, Olowski, Paul,F, 615, 2221672

10014, Orlando, Myron, NULL, 615, 2971228

invoice:

1001, 10011, 2008-08-03

1002, 10014, 2008-08-04

1003, 10012, 2008-03-20

1004, 10014, 2008-09-23

line:

1001, 12321, 1

1001, 65781, 3

1002, 34256, 6

1003, 12321, 5

1002, 12321, 6

product:

12321, hammer, 189 ,20, 232

65781, chain, 12, 45, 235

34256, tape, 35, 60, 235

12333, hanger, 200 ,10, 232

vendor:

232, Bryson, Smith, 615, 2233234

235, SuperLoo, Anderson, 615, 2158995

1- Find how many invoices are made by each customer. The output should be a list of cus_code and for each cus_code, the number of invoices made by this customer.

2- Find the total value for all products in the inventory. The total value in the inventory is the sum of product quantity * product price for all products listed in the product table.

3- Find vendor code, vendor contact and the number of products supplied by each vendor.

4- Create a view Alfred that contains customer code, customer last name, and number of invoices made by each customer who has a first name of Alfred.

5- For each invoice, find the total price. The total invoice price is the sum of product price* line units for each product purchased in the invoice.

6- Find how many products are bought by each customer. The output should be a list of cus_code and for each cus_code, the number of products purchased by this customer. A more complex query (if you want to try it), would be to list the name of the customer, along with the cus_code.

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

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions

Question

4. Identify the supernatural aid in The Wizard of Oz.

Answered: 1 week ago

Question

Explain basic guidelines for effective multicultural communication.

Answered: 1 week ago

Question

Identify communication barriers and describe ways to remove them.

Answered: 1 week ago

Question

Explain the communication process.

Answered: 1 week ago