You are on page 1of 7

VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com

CS403 ASSIGNMENT 3 SOLUTION FALL 2022


Provide by VU Answer

Total Marks: 20
Due Date: 15 Feb 2022

Must Follow Assignment Uploading or Special Instruction:


Assignment should be in .doc or .docx format.
Save your assignment with your ID (e.g. bx020200786.doc).

Note:
Your answer must follow the below given specifications.

 Font style: “Times New Roman”


 Font color: “Black”
 Font size: “12”
 Bold for heading only.
 Font in Italic is not allowed at all.
 No formatting or bullets are allowed to use.

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com
Question:
Perform the following tasks by considering the above given diagram.

You are required to write the SQL commands for each of the following statements.

1. Create a table named Booking. You also have to define primary key and foreign key (if any).

Solution:

CREATE TABLE Booking(


Bk_id int NOT NULL,
Bk_Date Date NOT NULL,
Driver_option varchar(255),
PRIMARY KEY (Bk_id)
);

2. Create a table named Agreement. You also have to define primary key and foreign key (if
any).

Solution:

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com

CREATE TABLE Agreement (


Agre_id int NOT NULL,
Duration varchar(255) NOT NULL,
Fuel varchar(255) NOT NULL,
Rent_fee int(20) NOT NULL,
Return_date Date NOT NULL,
PRIMARY KEY (Agre_id)
);

3. Show the age, Name and Address of Driver: and make sure that selected column should not
contain any duplicated values.

Solution:

SELECT DISTINCT age, Name, Address FROM Driver;

4. Change the Data type of Feedback_desc column from varchar (100) to Text in Feedback
table.

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com

Solution:

ALTER TABLE Feedback


ALTER COLUMN Feedback_desc Text;

5. Insert one record in Agreement table having data against each column (Agre_Id: 01,
Duration: 2 days, Fuel: 5 litter, Rent_fee: 5000, Return_date: 15/03/2022).

Solution:

INSERT INTO Agreement(Agre_Id, Duration, Fuel, Rent_fee, Return_date) VALUES ('01', '2
days', '5 liter', '5000', ‘15/03/2022’);

6. Delete columns Bk_Date and Driver_option from table Booking.

Solution:

ALTER TABLE Booking

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com
DROP COLUMN Bk_Date, Driver_option;

7. Show the Name in Upper case latter and Contact_No of those customers whose ages are
between 30 to 60 from Customer table.

Solution:

SELECT UPPER(Name), Contact_No FROM customer WHERE ages BETWEEN 30 AND 60;

8. Display the Bk_Date in ascending order and Driver_option of all those booking where
driver_option should be yes from Booking table.

Solution:

SELECT Bk_Date, Driver_option FROM Booking WHERE Driver_option = ‘Yes’ ORDER BY


Bk_Date_Asc;

9. Display sum, minimum, maximum and average Rent_fee from agreement table.

Solution:

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com

SELECT SUM(Rent_fee) AS Vehicle_Rent_Fee,


MIN(Rent_fee) AS Vehicle_Min_Fee,
MAX(Rent_fee) AS Vehicle_Max_Fee,
AVG(Rent_fee) AS Vehicle_AVG_Fee from Agreement;

10. What is the maximum Total_amount and average total_payable for each pay_status in
payment table.

Solution:

SELECT MAX(Total_amount) AS Total_Amount,


AVG (Total_payable) as Total_Payable GROUP BY pay_status;

REMEMBER IN PRAYERS

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J
VISIT ANY MORE FREELY SOLUTIONS

VUAnswer.com

REGARD SARIM
WHATSAPP +923162965677

PLEASE NOTE:
Don't copy-paste the same answer.
Make sure you can make some changes to your solution file
before submitting copy paste solution will be marked zero.
If you found any mistake then correct yourself and inform me.
Before submitting an assignment check your assignment
requirement file.
If you need some help and question about file and solutions.

MORE ANY ASSIGNMENTS SOLUTION FREE


VUAnswer.com

SUBSCRIBE OUR CHANNEL


https://www.youtube.com/channel/UCvFS8fAv4bvZsOmWu
WMIg3Q

JOIN WHATSAPP GROUP


https://chat.whatsapp.com/CbEPu7qfeNV8v0dZd5yT8J

You might also like