Cs 403 assignment no 3 fall 2022 by vu university
Assignment # 3 (CS403)
Solution:
1. Create a table named Booking. You also have to define theprimary key
and foreign key (if any).
Answer:
CREATE TABLE Booking (
bookingId INT, bookingdate
DATE, driverOption VARCHAR,
PRIMARY KEY (bookingId)
FOREIGN KEY (driver) REFERENCES Driver (License No)
);
2. Create a table named Agreement. You also have to definethe primary key
and foreign key (if any).
Answer:
CREATE TABLE Agreement
AgreementId INT,
Duration INT, Rentfee
Decimal, ReturnDate
DATE,
(
PRIMARY KEY (AgreementId)
);
3. Show he age, Name, and Address of the Driver: and makesure that selected
column should not contain any duplicatedvalues.
The syntax for selecting SQL:
SELECT column1, column2, …FROM
table_name;
Answer:
SELECT DISTINCT Age, Name,AddressFROM
Driver;
4. Change the Data type of Feedback_desc column fromvarchar (100)
to Text in Feedback table.
The syntax for changing data type:
ALTER TABLE Table-name
ALTER COLUMN Column datatype;
Answer:
ALTER TABLE Feedback, ALTER
Column Feedback-descText;
5. Insert one record in Agreement table having data againsteach column
(Agre_Id: 01, Duration: 2 days, Fuel: 5 litter, Rent_fee: 5000, Return_date:
15/03/2022).
Syntax for Inserting data;
INSERT INTO table name (column 1,
column2,……); VALUES (value 1,
value2……);
Answer:
INSERT INTO Agreement (Agree id,
Duration, Fuel, Rentee)Return-date)
VALUES(01,2,500, ‘15/03/2022’);
6. Delete columns Bk_Date and Driver_option from tableBooking.
Syntax for Deleting Columns:
ALTER TABLE Table name
DROP COLUMN Coulmn 1,column 2,…;
Answer:
ALTER TABLE Booking DROP
COLUMNS BK-Date;
Driver-option;
7. Show the Name in Upper case latter and Contact_No ofthose customers
whose ages are between 30 to 60 from Customer table.
Syntax to converts a string to upper-case.
SELECT UPPER(Column1, column2….)FROM
Table-name;
Answer:
30