0% found this document useful (0 votes)
66 views4 pages

MySQL Questions and Answers Guide

The document contains a series of MYSQL questions and SQL queries related to database concepts and operations. It covers topics such as DDL, DML, table creation, normalization, candidate keys, and various SQL commands for data retrieval and manipulation. Additionally, it includes practical exercises with sample tables and expected outputs for SQL queries.

Uploaded by

aanchal2008gupta
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)
66 views4 pages

MySQL Questions and Answers Guide

The document contains a series of MYSQL questions and SQL queries related to database concepts and operations. It covers topics such as DDL, DML, table creation, normalization, candidate keys, and various SQL commands for data retrieval and manipulation. Additionally, it includes practical exercises with sample tables and expected outputs for SQL queries.

Uploaded by

aanchal2008gupta
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

SHEORAN INTERNATIONAL SCHOOL

GREATER NOIDA

GRADE – XII
SUBJECT – INFORMATION PRACTICIES (065)
MYSQL Question answers
1. What are DDL and DML?
2. Give the SQL statement to create a table STUDENT with fields Roll Number, Name, Age, and Marks.
3. Create a table named PROGRAMMERS with the following structure:
P-Name (20 Characters)
DOJ DATE
SALARY NUMBER
(i) Display the name of the programmer with the highest salary.
(ii) Update the salary of all programmers by 2000 whose name starts with letter 'R'.
4. Explain the concept of candidate keys with an appropriate example.
5. Explain the concept of cartesian product between two tables with an example.
6. What is primary and alternate key in a database? Give an example.
7. Define primary key with a meaningful table example.
8. What do you understand by normalization?
9. Consider the following relations Teach (Name, Address, Course)
Give an expression in the relational algebra for each of the following:
(i) Print info about teachers teaching ‘DBMS’.
(ii) Print names and addresses of teachers who teach ‘computer’.
(iii) List teachers who live in Mumbai.
10. Observe the following table carefully and write the names of the most appropriate columns, which
can be considered as (i) candidate keys and (ii) primary key.
Table: Product
CID CNAME AMOUNT COUNTRY ITEM
101 ALLE 100000 JMEKA SHOES
111 BEN 20000 FRANCE HELMET
110 RIKI 25000 AMERICA BAG
011 BRETT LEE 105000 AUSTRALIA BAT
11. Write SQL queries:
SHOPPE Table
Id SName Area
S001 ABC Computeronics CP
S002 All Infotech Media GK II
S003 Tech Shoppe CP
S004 Geeks Tecno Soft Nehru Place
S005 Hitech Tech Store Nehru Place
ACCESSORIES Table
No Name Price Id
A01 Mother Board 12000 S01
A02 Hard Disk 5000 S01
No Name Price Id
A03 Keyboard 500 S02
A04 Mouse 300 S01
A05 Mother Board 13000 S02
A06 Keyboard 400 S03
A07 LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T10 Hard Disk 4500 S03
(a) Write the SQL queries:
(i) Display Name and Price of Accessories in ascending order of Price.
(ii) Display Id and SName of all Shoppe located in Nehru Place.
(iii) Display Min and Max price for each accessory Name.
(iv) Display Name and Price of Accessories with corresponding Shoppe Name.
(b) Write outputs of the following SQL queries:
(i) SELECT DISTINCT NAME FROM ACCESSORIES WHERE PRICE >= 5000;
(ii) SELECT AREA, COUNT(*) FROM SHOPPE GROUP BY AREA;
(iii) SELECT COUNT(DISTINCT AREA) FROM SHOPPE;
(iv) SELECT NAME, PRICE * 0.05 AS DISCOUNT FROM ACCESSORIES WHERE SNO IN ('S02','S03');
12. Write SQL queries for (a) to (f) and write the output for the SQL queries mentioned in (g) parts (i) to
(iv) on the basis of tables ITEMS and TRADERS :
ITEMS Table
Code IName Qty Price Company Tcode
1001 DIGITAL PAD 121 120 11000 XENITA T01
1006 LED SCREEN 40 70 38000 SANTORA T02
1004 CAR GPS SYSTEM 50 2150 GEOKNOW T01
1003 DIGITAL CAMERA 12X 160 8000 DIGICLICK T02
1005 PEN DRIVE 32 GB 600 1200 STOREHOME T03
TRADERS Table
Tcode TName City
T01 ELECTRONIC SALES MUMBAI
T03 BUSY STORE CORP DELHI
T02 DISP HOUSE INC CHENNAI
(a) Display details of all items in ascending order of item names.
(b) Display item name and price for items with price between 10000 and 22000.
(c) Display number of items traded by each trader.
T01 2
T03 1
T02 2

(d) Display Price, Item Name and Quantity for items with quantity > 150.
(e) Display names of traders from DELHI or MUMBAI.
(f) Display Company Name and Item Name in descending order of company.
(g) Write outputs of the following SQL queries:
(i) SELECT MAX(Price), MIN(Price) FROM ITEMS;
(ii) SELECT Price * Qty AS AMOUNT FROM ITEMS WHERE Code = 1004;
(iii) SELECT DISTINCT Tcode FROM ITEMS;
(iv) SELECT IName, TName FROM ITEMS I, TRADERS T WHERE [Link] = [Link] AND Qty < 100;
13. Write SQL queries:
APPLICANTS Table
No Name Fee Gender C_ID JoinYear
1012 Amandeep 30000 M A01 2012
1102 Avisha 25000 F A02 2009
1103 Ekant 30000 M A02 2011
1049 Arun 30000 M A03 2009
1025 Amber 40000 M A02 2011
1106 Ela 40000 F A05 2010
1017 Nikita 35000 F A03 2012
1108 Arluna 30000 F A03 2012
2109 Shakti 35000 M A04 2011
1101 Kirat 25000 M A01 2012
COURSES Table
C_ID Courses
A01 FASHION DESIGN
A02 NETWORKING
A03 HOTEL MANAGEMENT
A04 EVENT MANAGEMENT
A05 OFFICE MANAGEMENT
(a) Display NAME, FEE, Gender, JOINYEAR of applicants who joined before 2010.
(b) Display names of applicants paying FEE more than 30000.
(c) Display names of all applicants in ascending order of JOINYEAR.
(d) Display year and number of applicants who joined in each year.
(e) Display C_ID and number of applicants per course.
(f) Display applicant name with respective course name.
(g) Write outputs of the following SQL queries:
(i) SELECT NAME, JOINYEAR FROM APPLICANTS WHERE GENDER='F' AND C_ID='A02';
(ii) SELECT MIN(JOINYEAR) FROM APPLICANTS WHERE GENDER='M';
(iii) SELECT AVG(FEE) FROM APPLICANTS WHERE C_ID='A01' OR C_ID='A05';
(iv) SELECT SUM(FEE), C_ID FROM APPLICANTS GROUP BY C_ID HAVING COUNT(*) = 2;
14. Write SQL commands for (a) to (f) and write the outputs for (g) on the basis of table STUDENT:
STUDENT Table
SNO Name Stream Fees Age Sex
1 ARUN KUMAR COMPUTER 750.00 17 M
2 DIVYA JENEJA COMPUTER 750.00 18 F
3 KESHAR MEHRA BIOLOGY 500.00 16 M
4 HARISH SINGH [Link] 350.00 18 M
5 PRACHI ECONOMICS 300.00 19 F
6 NISHA ARORA COMPUTER 750.00 15 F
SNO Name Stream Fees Age Sex
7 DEEPAK KUMAR ECONOMICS 300.00 16 M
8 SARIKA VASWANI BIOLOGY 500.00 15 F

(a) List names of all students with COMPUTER stream.


(b) Count number of female students.
(c) Display student count stream-wise.
(d) Insert: 9, 'KARISHMA', 'ECONOMICS', 300.18, 'F'
(e) Display NAME, STREAM, SEX, and stipend (20% of FEES).
(f) Display records sorted by NAME.
(g) Write outputs of the following SQL queries:
(i) SELECT AVG(FEES) FROM STUDENT WHERE STREAM = 'COMPUTER';
(ii) SELECT MAX(AGE) FROM STUDENT;
(iii) SELECT COUNT(DISTINCT STREAM) FROM STUDENT;
(iv) SELECT SUM(FEES) FROM STUDENT GROUP BY STREAM;
15. Write SQL commands for (a) to (d) and write the outputs for (e) and (f) on the basis of table
EMPLOYEE:
(a) List employees older than 34 years sorted by NAME.
(b) Display report with NAME, BASIC, DEPARTMENT, and annual salary (BASIC × 12).
(c) Count employees in PERSONNEL or COMPUTER department.
(d) Insert: 11, 'VIJAY', 9300, 'FINANCE', '13/7/98', 35, 'M'
(e) Write outputs of the following SQL queries:
(i) SELECT SUM(BASIC) FROM EMPLOYEE WHERE DEPARTMENT = 'PERSONNEL';
(ii) SELECT AVG(BASIC) FROM EMPLOYEE WHERE SEX = 'F';
(iii) SELECT MAX(BASIC) FROM EMPLOYEE WHERE DATEOFAPP > '22/02/97';
(iv) SELECT COUNT(DISTINCT DEPARTMENT) FROM EMPLOYEE;
(f) Based on tables EMPLOYEE and INCHARGE, write output of:
INCHARGE Table
Dept Head
PERSONNEL RAHUL
COMPUTER SATYAM
ACCOUNTS NATH
FINANCE GANESH
MAINTENANCE JACOB
SELECT NAME, HEAD FROM EMPLOYEE E, INCHARGE I WHERE [Link] = [Link];

You might also like