Learn › Class 12 › Computer Science / Informatics Practices › Databases and SQL
Databases and SQL
Work it out on paper first. Then check the hint or the answer.
1. A table has 5 columns and 12 rows. What is its degree?
Hint
Degree counts columns.
Answer and explanation
Answer: 5
Degree = number of attributes = 5; cardinality would be 12.
2. Table A has 4 rows and table B has 3 rows. How many rows are in their Cartesian product?
Hint
Every row pairs with every row.
Answer and explanation
Answer: 12
4 × 3 = 12 rows.
3. A table has 10 rows, and Phone is NULL in 3 of them. What does SELECT COUNT(Phone) return?
Hint
COUNT(column) skips NULLs.
Answer and explanation
Answer: 7
Only the 7 non-NULL values are counted; COUNT(*) would give 10.
4. Write a query to show the names of students whose name starts with 'A'.
Hint
Use LIKE with %.
Answer and explanation
Answer: SELECT Name FROM STUDENT WHERE Name LIKE 'A%';
'A%' matches A followed by any characters.