Page 287 - Information_Practice_Fliipbook_Class11
P. 287
(iv) <NULL, "D", "Science", "Vinayak Damodar">
Error: Violation of entity integrity constraint. ClassId is part of the primary key, so cannot be NULL.
(v) <11, "D", "Science", "Sona Sahu">
Insertion will be successful as there is no problem in repeating Stream and ClassTeacher. The same teacher can be a
class teacher for more than one class. But if this is not allowed, we will have to declare that ClassTeacher is UNIQUE.
(vi) <11, "D", NULL, NULL>
Insertion will be successful as non-key attributes can be NULL unless otherwise mentioned.
(vii) <11, "c", "Commerce","Ananya Kasaravall">
Insertion will be successful as Section "c" is different from Section "C".
7. Which of the following are correct values for the given data types?
Type Value
(i) char(20) a. 'R Vasudevan'
(ii) float b. 1394.78
(iii) integer c. 218,790
(iv) date d. '1998-5-12'
(v) integer e. 4150987
Ans. Correct field values: (a), (b), (d) and (e)
8. Name any two aggregate functions used in SQL.
Ans. min(), max()
9. Write an SQL statement to open a database named MyDB.
Ans. USE MyDB;
10. Differentiate between ALTER TABLE and UPDATE…SET statements.
Ans. While ALTER TABLE is used to modify the structure of the table, UPDATE … SET statement is used to modify the
values of the attributes in the table.
11. Categorise the following statements into DDL and DML.
SELECT, DELETE, CREATE TABLE, UPDATE…SET, DROP TABLE
Ans. DDL - CREATE TABLE, DROP TABLE
DML - SELECT, DELETE, UPDATE…SET
12. Which clause is used to display a column value only once?
Ans. DISTINCT
13. Which clause is used to display the results of a query in ascending or descending order?
Ans. ORDER BY
14. Consider the following query:
SELECT SName FROM Subjects WHERE SName like ???
Which string should replace ??? to display the names of the subjects that end with 'CE'?
Ans. '%CE'
15. Consider the table TRAVEL given below and write the SQL queries (i) to (viii).
Table: TRAVEL
+-----+-----------+------------+----------+-----------+--------------+------------+
| CNo | CName | TravelDate | Distance | NPersons | Destination | CAT |
+-----+-----------+------------+----------+-----------+--------------+------------+
| 101 | Shaloo | 2022-03-10 | 340 | 4 | Srinagar | Hill Station |
| 102 | Sonia | 2022-03-10 | 224 | 4 | Jaipur | Historical |
| 103 | Abhimanyu | 2022-01-01 | 510 | 2 | Goa | Beach |
| 104 | Senthil | 2022-10-05 | 125 | 5 | Chandigarh | NULL |
| 105 | Gurvinder | 2022-07-18 | 460 | 1 | Goa | Beach |
| 106 | Penny | 2022-08-08 | 0 | 3 | Null | Null |
+-----+-----------+------------+----------+-----------+------------+--------------+
(i) Display names of customers who want to travel to a hill station.
Database Concepts and the Structured Query Language 273

