MBOSE Class XI Informatics Practices · Chapter 8
Introduction to Structured Query Language (SQL)
Opening soonHow to create a database and tables in MySQL, put data in them, ask questions with `SELECT … WHERE`, and change the data with `UPDATE` and `DELETE`.
15 lessons · 73 practice questions
What this chapter covers
- Advantages of SQL
- Data Definition Language (DDL), Data Query Language (DQL) and Data Manipulation Language (DML)
- Introduction to MySQL, creating a database using MySQL, data types
- Data Definition:
CREATE DATABASE,CREATE TABLE,DROP,ALTER - Data Query:
SELECT,FROM,WHEREwith relational operators,BETWEEN, logical operators,IS NULL,IS NOT NULL - Data Manipulation:
INSERT,DELETE,UPDATE - The NCERT chapter also uses
DISTINCT, aliases,IN,LIKEandORDER BY, so they are taught as well
Key terms
- SQL
Structured Query Language
- DDL / DML / DQL
Language for definition / manipulation / query of data
- Constraint
A rule on the data of a column
- Query
A request to the database
- Alias
A name given to a column or expression in the result
- Derived column
A column calculated in the result, not stored in the table
- NULL
Unknown or missing value
- Wild card
%(any characters) and_(one character) inLIKE
Important questions with answers
10 of the 73 questions on this chapter, solved.
Question 1 · Multiple choice · 1 mark
SQL stands for
- (a) Structured Query Language
- (b) Simple Question Language
- (c) Standard Query Logic
- (d) Sorted Query List
Answer: (a) Structured Query Language
The standard language of relational databases.
Question 2 · Multiple choice · 1 mark
A column that refers to the primary key of another table is a
- (a) composite key
- (b) unique key
- (c) foreign key
- (d) candidate key
Answer: (c) foreign key
FOREIGN KEY ... REFERENCES.
Question 3 · Multiple choice · 1 mark
Which command changes existing values?
- (a) ALTER
- (b) UPDATE
- (c) INSERT
- (d) CREATE
Answer: (b) UPDATE
UPDATE ... SET.
Question 4 · Multiple choice · 1 mark
To test a missing value we write
- (a) Bonus EQUALS NULL
- (b) Bonus = NULL
- (c) Bonus == NULL
- (d) Bonus IS NULL
Answer: (d) Bonus IS NULL
NULL cannot be compared with =.
Question 5 · Assertion and reason · 1 mark
Assertion (A): The primary key column cannot contain NULL.
Reason (R): A primary key identifies a row uniquely.
- (a) Both A and R are true, and R is the correct explanation of A.
- (b) Both A and R are true, but R is not the correct explanation of A.
- (c) A is true, but R is false.
- (d) A is false, but R is true.
Answer: (a) Both A and R are true, and R is the correct explanation of A.
R explains A.
Question 6 · Short answer · 1 mark
Expand SQL.
Answer
Structured Query Language.
Question 7 · Short answer · 2 marks
Name the three groups of SQL commands with one command each.
Answer
DDL – CREATE; DML – INSERT; DQL – SELECT.
Question 8 · Short answer · 3 marks
For the BOOK table above write queries to (a) list the books costing more than 300 (b) show the titles in alphabetical order (c) change the price of BookID 1 to 275.
SELECT Title, Price FROM BOOK WHERE Price > 300; SELECT Title FROM BOOK ORDER BY Title; UPDATE BOOK SET Price = 275 WHERE BookID = 1; SELECT * FROM BOOK WHERE BookID = 1;Output:
+--------------------+-------+ | Title | Price | +--------------------+-------+ | Python Basics | 400 | | Maths for Class XI | 350 | +--------------------+-------+ 2 rows in set +--------------------+ | Title | +--------------------+ | Khasi Folk Tales | | Maths for Class XI | | Python Basics | +--------------------+ 3 rows in set Query OK, 1 row affected +--------+------------------+-------+ | BookID | Title | Price | +--------+------------------+-------+ | 1 | Khasi Folk Tales | 275 | +--------+------------------+-------+ 1 row in setAnswer
One mark for each statement.
Question 9 · Long answer · 5 marks
Explain the groups of SQL commands, data types and constraints of MySQL.
Answer
Section 1.1.
Question 10 · Long answer · 5 marks
Explain ALTER and DROP with examples.
Answer
Section 1.3.
Study the whole chapter
15 step-by-step lessons, all 73 practice questions with hints, flashcards and mock tests for MBOSE Class XI Informatics Practices.