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
10 points (queries)
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 :
*************************************
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 :
*************************************
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 :
*************************************
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 :
*************************************
Question 3 :
SQL Query :
/*Query 3*/
update supplier set Supplier_Address='Delhi' where
supplier_id='S01';
/*selecting record*/
select * from supplier;
Screen in SSMS:
*************************************
Question 4 :
SQL Query :'
/*Query 4*/
alter table supplier add Supplier_Tax_ID varchar(10);
/*selecting record*/
select * from supplier;
Screen in SSMS :
*****************************
Question 5:
SQL Query :
/*Query 5*/
select Customer_Telephone from customer where
Customer_ID='C01';
Screen in SSMS :
********************************
Question 6 :
SQL Query :
select Customer_Name from Customer , invoice where
Customer.Customer_ID=Invoice.Customer_ID and
Part_Number='P01';
Screen in SSMS :
************************************
Question 7:
SQL Query :
select min(parts_price) from parts;
Screen in SSMS :
*************************************
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 :
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
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...
Please finish all 6 parts with indexing SQL. Don't need to do the measure time things, but you can do it if you wanna do it. Thanks! Write the following SQL queries and measure their execution time both with and without using indexes 1. Count how many parts in NYC have more than 70 parts on hand 2. Count how many total parts on hand, in both NYC and SFO, are Red 3. List all the suppliers that have more...
Project Steps: 1. Database Design 1.1. Design and create a database in third normal form based on the following requirements: • Each Job is for a specific customer and there can be more than one job per customer. • The name and address must be tracked for each customer. • Each job is described by up to 2000 characters. • Each job has a status of ‘open, ‘in process’, or ‘complete’. • Each job has a start date and end...