Assignment_12_SQL(25)
Assignment_12_SQL(25)
UNIT- 3
CHAPTER: DBMS & SQL SYNTAXES
1 Define the following terms:
i) DBMS ii) Data integrity iii) Data Reliability iv)SQL
v) Referential Integrity
2. Define the following terms: To view all the values from a table
i) Degree ii) Cardinality iii) Tuple
iv) Relation v) Domain vi) Attribute vii) Keys
3 Explain the following keys:
i) Candidate key ii) Primary key iii) Alternate key iv) Foreign key
4 Write about DDL & DML commands
5 Write the syntax and eg for the following:
i) To create database ii) To open a database
ii) To view the databases iv) To delete the database
iv) To create a table v)To view tables in the database
v) To describe table properties vii)To delete the table
4 Consider the table Flight given below, write command in SQL for (i) to (iv) and output for
(v) to (viii)
(i)To display names of drivers and destination city where TELEVISION is being
transported.
(ii) To display driver names and destinations where destination is not MUMBAI.
(iii) To display the names of destination cities where items are being transported. There
should be no duplicate values.
(iv) To display details of rowsthat have some value in DRIVERGRADE column.
(v) To display names of drivers, names of items and travel dates for those items that are
being transported on or before 1st April 2019.
(vi) To display the number of drivers who have ‘MOHAN’ anywhere in their names.
(vii) To display the names of drivers, item names and travel dates in alphabetic
(ascending) order of driver names.
(viii) To display names of drivers whose names are three characters long.
6 Consider the table given below. Write SQL queries for (i) to (vii).
Columns REGID stores Registration Id, PREWEIGHT stores weight of the person before
joining
Gym, CURRWEIGHT stores current weight, DOJ stores Date of Joining, BRANCH stores
the
branch of Gym where the person has enrolled.
(i) To display names of members along with their previous and current weights who are in
Model Town branch.
(ii) To display all names of members, previous weight, current weight, Change in weight
(i.e.how much increase from previous weight or decrease from previous weight, Decrease
will be displayed with negative sign)
(iii) To display BRANCH wise count of members in the Gym. (i.e. display the BRANCH
and number of members in each BRANCH)
(iv) To display names and date of joining of all the members who joined in the year 2018.
(v) To display Names and Current weight of all the members in descending order of Current
Weight.
(vi) To display the names and date of joining of male members who have joined after 27th
September 2018.
(vii) To display names and date of joining of members who have their names starting with
‘S’and ending with ‘a’.
7
(a) To display all information about the CUSTOMERs whose NAME starts with
'A'.
(b) To display the NAME and BALANCE of Female CUSTOMERs (with GENDER as
'F') whose TRANSACTION Date (TDATE) is in the year 2019.
(c) To display the total number of CUSTOMERs for each GENDER.
(d) To display the CUSTOMER NAME and BALANCE in ascending order of GENDER.
(e) To display CUSTOMER NAME and their respective INTEREST for all
CUSTOMERs where INTEREST is calculated as 8% of BALANCE.
8
Write SQL queries for a to d, which are based on the tables :
CUSTOMERS and PURCHASES then write the outputs for (i) to (iii)
a) To display details of all CUSTOMERS whose CITIES are
neither Delhi nor Mumbai.
b) To display the CNAME and CITIES of all CUSTOMERS in
ascending order of their CNAME.
c) To display the number of CUSTOMERS along with their
respective CITIES in each of the CITIES.
d) To display details of all PURCHASES whose Quantity is
more than 15.
9
10