Question

1. Create the following tables and establish relationships. All fields are Varchar except parts price and date. Invoice Invoice_ID Customer_ID Part_Number Date...

1. Create the following tables and establish relationships.

All fields are Varchar except parts price and date.

Invoice

Invoice_ID

Customer_ID

Part_Number

Date

Customer

Customer_ID

Customer_Name

Customer_Address

Customer_Telephone

Parts

Part_Number

Part_Description

Parts_Price

Supplier_ID

Supplier

Supplier_ID

Supplier_Name

Supplier_Address

Sales_Rep

10 points

2. Populate data (you make it up) use at least one insert into query for each table the rest you can enter in grid view.

10 points (queries)

3. Update one of the supplier’s address.
4. Add a field named supplier tax ID to the supplier table.
5. What is the telephone number of a particular customer?
6. What is the name of every customer who has purchased a certain part?
7. What part has the lowest price?
8. Which customer names purchased something within the last three 3 days?
9. What are the invoice IDs of parts purchased from a particular sales rep?


SQL
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

This demonstration is using SQL Server 2014.Database and Tables are created using SQL Server Management Studio (SSMS)

Database :

create database ERPDB;

/*use database to create tables*/
use ERPDB;

Tables :

1.Table Name :Customer

SQL Query :

/*1.Table Name :Customer*/
create table Customer(
Customer_ID varchar(10) primary key,
Customer_Name varchar(20) not null,
Customer_Address varchar(100) not null,
Customer_Telephone varchar(10) not null
);

/*inserting records*/
insert into Customer values ('C01','Virat Kohli','Chandni Chowk Mumbai','8888881245');

/*selecting records*/
select * from Customer;

Screen in SSMS :

1 ERPDB.sql - NAGESH-PC.ERPDB (NAGESH-PCNagesh (54) Microsoft SQL Server Managemen... File Edit View Query Project Debug Tool

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

2.Table Name :Supplier

SQL Query :

/*2.Table Name :Supplier*/
create table Supplier(
Supplier_ID varchar(10) primary key,
Supplier_Name varchar(20) not null,
Supplier_Address varchar(100) not null,
Sales_Rep varchar(10) not null
);

/*inserting records*/
insert into Supplier values ('S01','ABC Corp','Tilak Road Pune','Mr.Sam');

/*selecting records*/
select * from Supplier;

Screen in SSMS :

ERPDB.sql - NAGESH-PC.ERPDB (NAGESH-PCNagesh (54)) - Microsoft SQL Server Managem... File Edit View Query Project Debug Tools

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

3.Table Name :Parts

SQL Query :

/*3.Table Name :Parts*/
create table Parts(
Part_Number varchar(10) primary key,
Part_Description varchar(100) not null,
Parts_Price decimal(6,2) not null,
Supplier_ID varchar(10) not null,
foreign key (Supplier_ID) references Supplier(Supplier_ID)
);

/*inserting records*/
insert into Parts values ('P01','Hammer',100.25,'S01');

/*selecting records*/
select * from Parts;

Screen in SSMS :

ERPDB.sql - NAGESH-PC.ERPDB (NAGESH-PCNagesh (54)) - Microsoft SQL Server Managem... File Edit View Query Project Debug Tools

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

4.Table Name :Invoice

SQL Query :

/*4.Table Name :Invoice*/
create table Invoice(
Invoice_ID varchar(10) primary key,
Customer_ID varchar(10) not null,
Part_Number varchar(10) not null,
Date date not null,
foreign key (Customer_ID) references Customer(Customer_ID),
foreign key (Part_Number) references Parts(Part_Number)
);

/*inserting records*/
insert into Invoice values ('I01','C01','P01','02/05/2018');

/*selecting records*/
select * from Invoice;

Screen in SSMS :

ERPDB.sql NAGESH-PC.ERPDB (NAGESH-PCNagesh (54)- Microsoft SQL Server Managem... File Edit View Query Project Debug Tools Win

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

Question 3 :

SQL Query :

/*Query 3*/
update supplier set Supplier_Address='Delhi' where supplier_id='S01';

/*selecting record*/
select * from supplier;

Screen in SSMS:

ERPDB.sql NAGESH-PC.ERPDB (NAGESH-PCNagesh (54)- Microsoft SOL Server Manageme. File Edit View Query Project Debug Tools Wind

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

Question 4 :

SQL Query :'

/*Query 4*/
alter table supplier add Supplier_Tax_ID varchar(10);

/*selecting record*/
select * from supplier;

Screen in SSMS :

ERPDB.sql - NAGESH-PC.ERPDB (NAGESH-PCNagesh (54) - Microsoft SQL Server Manageme...- File Edit View Query Project Debug Tool

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

Question 5:

SQL Query :

/*Query 5*/
select Customer_Telephone from customer where Customer_ID='C01';

Screen in SSMS :

땟 ERPDB.sql-NAGESH-PC.ERPDB (NAGESH-PaNagesh (54))-Microsoft SQL Server Manageme.. File Edit View Query Project Debug Tools

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

Question 6 :

SQL Query :

select Customer_Name from Customer , invoice where
Customer.Customer_ID=Invoice.Customer_ID and
Part_Number='P01';

Screen in SSMS :

安ERPDB.sql-NAGESH-PC.ERPDB (NAGESH-PCNagesh (54))-Microsoft SQL Server Manageme...- File Edit View Query Project Debug Tools

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

Question 7:

SQL Query :

select min(parts_price) from parts;

Screen in SSMS :

ERPDB.sql - NAGESH-PC.ERPDB (NAGESH-PCNagesh (54))* - Microsoft SOL Server Manageme. File Edit View Query Project Debug Tools

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

Question 9:

SQL Query :

select invoice_id from invoice, parts,supplier
where Invoice.Part_Number=Parts.Part_Number and
Parts.Supplier_ID=Supplier.supplier_ID and
Sales_Rep='Mr.Sam';

Screen in SSMS :

ERPDB.sql - NAGESH-PC.ERPDB (NAGESH-PCNagesh (54))* - Microsoft SOL Server Manageme. File Edit View Query Project Debug Tools

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
1. Create the following tables and establish relationships. All fields are Varchar except parts price and date. Invoice Invoice_ID Customer_ID Part_Number Date...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT