2 3mark
2 3mark
2. There is a column Salary in a Table EMPLOYEE. The following two statements are
giving different outputs. What may be the possible reason?
SELECT COUNT(*) FROM EMPLOYEE;
SELECT C0UNT(Salary) FROM EMPLOYEE;
3. A table FLIGHT has 4 rows and 2 columns and another table AIRHOSTESS has rows
and 4 columns. How many rows and columns will be there if we obtain the cartesian
product of these two tables?
4. What is the purpose of GROUP BY clause in MySQL? How is it different from ORDER
BY clause?
7. Why is it not allowed to give String and Date type arguments for SUM() and AVG()
functions? Can we give these type of arguments for other functions?
11. There is a column C1 in a table T1. The following two statements: SELECT COUNT(*)
FROM T1; and SELECT COUNT(C1) from T1; are giving different outputs. What may
be the possible reason?
15. What are constraints? Are constraints useful or are they hindrances to effective
management of databases?
16. In a database there is a table Cabinet. The data entry operator is not able to put NULL in
a column of Cabinet? What may be the possible reason(s)?
17. In a database there is a table Cabinet. The data entry operator is not able to put duplicate
values in a column of Cabinet? What may be the possible reason(s)?
19. There is a table T1 with combination of columns C1, C2, and C3 as its primary key? Is it
possible to enter:
a.NULL values in any of these columns?
b.Duplicate values in any of these columns?
20. What are the differences between DELETE and DROP commands of SQL?
22. For what Data Types aggregate functions : MIN(), MAX(), and COUNT() work?
30. A table “transport” in database info has cardinality 8 and degree 3. What is the number of
column and row in transport relation.
Answers
1. Answer:
(i) re
(ii) 45
(iii) 01
(iv) 76.99
2. Answer:
SELECT COUNT (*)
FROM EMPLOYEE:
This statement returns the number of records in the table.
SELECT COUNT(Salary)
FROM EMPLOYEE;
This statement returns the number of values (NULL values will not be counted) of the
specified column.
3. Answer:
Total number of rows will be 12 and total number of columns will be 6.
4. Answer:
The GROUP BY clause can be used to combine all those records that have identical
value in a particular field or a group of fields. Whereas, ORDER BY clause is used to
display the records either in ascending or descending order based on a particular field.
For ascending order ASC is used and for descending order, DESC is used. The default
order is ascending order.
5. Answer:
SELECT Stream, MAX(Agg)
FROM EMPLOYEE
GROUP BY Stream;
6. Answer:
Differences between Now() and SYSDATE() of MySql are as follows:
7. Answer :
String and dates are not real numbers that we calculate so sum or avg functions are not
valid for them.
8. Answer :
By default, Autocommit mode is on in MySQL.
9. Answer :
We can add a savepoint anywhere in a transaction.
10. Answer :
None of the aggregate functions takes NULL into consideration. NULL is simply ignored
by all the aggregate functions.
11. Answer :
There may be a null value.
12. Answer :
GROUP BY clause is used in a SELECT statement in conjunction with aggregate
functions to group the result based on distinct values in a column.
13. Answer :
WHERE Vs HAVING: WHERE is used to put a condition on individual row of a table
whereas HAVING is used to put condition on individual group formed by GROUP BY
clause in a SELECT statement.
14. Answer :
Foreign Key: It is a column of a table which is the primary key of another table in the
same database. It is used to enforce referential integrity of the data.
15. Answer :
These are the rules which are applied on the columns of tables to ensure data integrity
and consistency. These play very important role for tables so are not hindrances.
16. Ansewr :
Not NULL or Primary key constraints used
17. Ansewr :
Primary key constraint used.
18. Answer :
No.
19. Answer :
No.
20. Answer :
Delete is used for row removing while drop is used for removing complete table.
21. Answer :
A multiple row function works on multiple values. These functions are called aggregate
functions or group functions.
22. Answer :
On any type of values - Numeric, Date, or String. AVG(), and SUM() work on only
Numeric values (INT and DECIMAL).
23. Answer :
HAVING clause is used in conjunction with GROUP BY clause in a SELECT statement
to put condition on groups.
24. Answer :
The property of a relational database which ensures that no entry in a foreign key column
of a table can be made unless it matches a primary key value in the corresponding column
of the related table.
25. Answer :
Union is an operation of combining the output of two SELECT statements.
26. Answer :
WHERE function is used for individual records and HAVING for groups . GROUP BY
function is used for getting results based on some groups of data while a condition on
groups is applied by HAVING clause.
27. Answer :
DROP TABLE command is used to delete tables.
28. Answer :
whenever a condition involves an aggregate function, then we use HAVING clause in
conjunction with GROUP BY clause.
29. Answer :
ALTER TABLE command can be used to Add, Remove, and Modify columns of a table.
It can also be used to Add and Remove constraints.
30. Answer:
Number of Row -8
Number of column- 3