MYSQL Booklet Answer Key (2022-23)
MYSQL Booklet Answer Key (2022-23)
(i) Data integrity : Data integrity is the accuracy, completeness, and reliability of data.
(ii) Relation: A table in an RDBMS is known as a relation.
(iii) Tuple: One complete row of information in a table is called a Tuple.
(iv) Attribute: One complete column of information in a table is called an Attribute.
(v) Degree : Total number of columns in a table.
(vi) Cardinality : Total number of rows in a table.
2. Expand the following:
(i) SQL: Structured Query Language
(ii) DDL: Data Definition Language
(iii) DBMS : Database Management System
(iv) RDBMS: Relational Database Management System
(v) TCL: Transaction control Language
3. What is data redundancy? How DBMS help in reducing problems associated with it?
Ans : Data redundancy occurs when the same piece of data is stored in two or more separate places.
A DBMS can reduce data redundancy and inconsistency by minimizing isolated files in which the same
data are repeated. .... Access and availability of information can be increased and program development
and maintenance costs can be reduced
4. How do database management systems ensure data security?
Ans : A database management system ensure data security and privacy by ensuring that only means of
access to the database is through the proper channel and also by carrying out authorization checks whenever
access to sensitive data is attempted.
5. What is default format for date datatype of MYSQL?
Ans : yyyy-mm-dd
6. What is Key? Define the following keys:
(i) Primary key : Afield in the table used to uniquely identify each record in it. It contains all unique
and not null values.
(ii) Candidate key : All attributes of a table that are eligible to become primary key.
(iii) Alternate key: after choosing primary key from candidates, the left of candidates are called
alternate keys
(iv) Foreign key : Primary of one table when appears in another table is called foreign key. It is used
to create joins in the tables.
(v) Composite key : Primary key made up of more than one field is called a composite key.
7. Write any two commands that belong to the following categories?
(i) DDL : Create table, Alter table, Drop table etc
(ii) DML : Select , Insert, Update , Delete
8. What is data type? Name some data types available in MySQL.
Data types determine the kind of data a column in the table is going to hold and kind of operations that can
be performed on it, e.g. integer, char, varchar, date , time etc
9. What is the use of Order by clause of MYSQL?
Ans : Order by clause is used to arrange data of the table based on any column in ascending or descending
order.
10. Differentiate between Char and Varchar data types?
Ans : Char is fixed length datatype and varchar is variable length datatype. If we put data less than the
maximum limit in char then rest of memory is wasted but in case of varchar datatype memory is
allocated as per the length of actual data so no wastage of memory.
11. Can we use int datatype of MYSQL to store mobile number of customers in bank table.
Ans : No, because mobile numbers go beyond the range of int datatype
12. Which keyword eliminates the duplicate data from a query result?
Ans : Distict
13. What command is used for-
(i) To change/open a database
Use dbname;
(ii) To view the table structure.
Desc tablename;
(iii) To see list of databases
Show databases;
(iv) To see list of tables in a database
Show tables;
(v) To modify table structure
Alter table
(vi) To modify data of a table
Update
(vii) To see structure of a table.
Desc tablename
14. Which comparison operator is used for comparing?
(i) Patterns
Like
(ii) null values
is
(iii) ranges
between
(iv) list of values
in
15. What is NOT NULL field?
Ans : afield in the table that does not allow entery of null values
16. When column’s value is skipped in an INSERT command, which value is inserted in the database?
Ans : NULL
17. Differentiate between DDL and DML commands?
1. DDL stands for Data Definition Language 1. DML stands for Data Manipulation
Language
2. eg. Create tabale, Alter table, Drop table etc 2. e.g Select, Imsert, Update and Delete
20. Write the SQL queries (i to v) and write the output of the following SQL commands (vi to ix ) on the basis
of the following table ITEM:
ITEM
INo IName Price SName AREA
T01 Mother Board 12000 ABC Computronics GK II
T02 Hard Disk 5000 ABC Computronics GK II
T03 Keyboard 500 All Infotech Media CP
T04 Mouse 300 ABC Computronics GK II
T05 Mother Board 13000 All Infotech Media CP
T06 Keyboard 400 Tech Shoppe Nehru Place
T07 LCD 6000 Hitech Tech Store CP
T08 LCD 5500 Hitech Tech Store CP
T09 Mouse 350 Hitech Tech Store CP
T10 Hard Disk 4500 Tech Shoppe Nehru Place
(i) To display IName and Price of all the items in the ascending order of their Price.
Select IName, Price from Item order by Price Asc;
(ii) To display the SName of all stores located in CP.
Select SName from Item where Area=”CP”;
(iii) To display a list of all the store names. (Without Repetition)
Select distinct SName from Item;
(iv) To display the IName, Price and SName of items with price in range of 1000 to 5000.
Select IName, Price , SName from Item where Price between 1000 and 5000;
(v) To display name of items which have ‘a’ somewhere in their name.
Select IName from item where IName like’%a%”;
(vi) SELECT DISTINCT INAME FROM ITEM WHERE PRICE >= 5000;
IName
Mother Board
Hard Disk
LCD
AREA
CP
CP
CP
CP
CP
GK II
GK II
GK II
Nehru Place
Nehru Place
(viii) SELECT DISTINCT AREA FROM ITEM;
AREA
GK II
CP
Nehru Place
(ix) SELECT INAME, PRICE*0.05 DISCOUNT FROM ITEM WHERE INO IN (‘T02’, ‘T03’);
IName DISCOUNT
Hard Disk 250.0000
Keyboard 25.0000