0% found this document useful (0 votes)
26 views6 pages

MYSQL Booklet Answer Key (2022-23)

The document provides an answer key for a MySQL assignment for Class XII, covering definitions of key terms, SQL commands, data types, and database management concepts. It includes explanations of data integrity, redundancy, security, and various SQL queries related to a teacher and item database. Additionally, it differentiates between DDL and DML commands and provides examples of SQL commands for specific queries.

Uploaded by

Soham Mukherjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views6 pages

MYSQL Booklet Answer Key (2022-23)

The document provides an answer key for a MySQL assignment for Class XII, covering definitions of key terms, SQL commands, data types, and database management concepts. It includes explanations of data integrity, redundancy, security, and various SQL queries related to a teacher and item database. Additionally, it differentiates between DDL and DML commands and provides examples of SQL commands for specific queries.

Uploaded by

Soham Mukherjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Delhi Public School, Gurgaon

MYSQL – Assignment 1 Answer Key


Class XII(2022-23)
1. Define the following terms :

(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

18. Differentiate between the following:


(i) DROP TABLE & DROP DATABASE
Drop table removes one particular table whereas drop database removes all tables in that database
(ii) DROP TABLE & DROP clause of ALTER TABLE
Drop table removes complete table whereas drop caluse of Alter table commad is used to remove
a column from the table.
(iii) WHERE and HAVING clause
Where clause is used to give condition for individual records, having is used to give condition
based on an aggregate and it can only be used with group by clause
(iv) Alter table and Update Table
Alter table is used to make changes in table structure whereas Update is used to modify table data.
19. Write SQL commands for the following queries based on the relation Teacher given below:
No Name Age Department Date_of_join Salary Gender
1 Jugal 34 Computer Sc 1997-01-10 12000 M
2 Sharmila 31 History 1998-03-24 20000 F
3 Sandeep 32 Maths 1996-12-12 30000 M
4 Sangeeta 35 History 1999-07-01 40000 F
5 Rakesh 42 Maths 1997-09-05 25000 M
6 Shyam 50 History 1998-06-27 30000 M
7 Shiv 44 Computer Sc 1997-02-25 21000 M
8 Shalakha 33 Maths 1997-07-31 20000 F

(i) To show all information about the teacher of History department.


Select * from Teacher where Department=”History”;
(ii) To list the names of female teachers who are in Maths department.
Select * from Teacher where Department= “ Maths” and Gender=”F”;
(iii) To list the names of all teachers with their date of joining in ascending order.
Select name, Date_of_join from teacher order by Date_of_join;
(iv) To display teacher’s name, salary, age for male teachers only.
Select Name, Age, Salary from Teacher where Gender=”M”;
(v) To display all details of teachers with Age in range of 25 to 40 (both values inclusive).
Select * from Teacher where Age between 25 and 40;
(vi) To display details of all teachers whose dateof joining is after 1998.
Select * from Teacher where Date_Of_Join >”1997-12-31”;
(vii) To insert a new row in the table with ANY relevant data.
Insert into Teacher values(9,”ABC”,35,”Maths”,”1997-12-12”,40000,”M”);
(viii) To display names in alphabetical order
Select Name from teacher order by name;
(ix) To display all details of teachers of Computer Sc and Maths Department.
Select * from teacher where Department in(“Maths”,”Computer Sc.”)
(x) To display all details of teachers with age below 30 or above 45.
Select * from teacher where age<30 or age>45;

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

(vii) SELECT AREA FROM ITEM ORDER BY AREA;

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

You might also like