SOLVED WORKSHEET – IP
Q1. Which of the following ensures uniqueness of every row in a table?
Answer: b) Primary key
Q2. Which SQL command is used to change the structure of an existing table?
Answer: c) ALTER
Q3. The number of rows in a table is known as its:
Answer: b) Cardinality
Q4. Which SQL clause is used to arrange the result set?
Answer: a) ORDER BY
Q5. To display records where the city starts with ‘A’ we use:
Answer: c) City LIKE 'A%'
Q6. Which SQL keyword is used to remove an entire table?
Answer: b) DROP
Q7. When a primary key from one table appears in another table, it becomes the:
Answer: b) Foreign key
Q8. Which is NOT a valid SQL data type?
Answer: d) INTEGER32
Q9. DCL stands for:
Answer: a) Data Control Language
Q10. A column that can accept NULL values is:
Answer: d) AUTO INCREMENT
Q11. Differences between Primary Key and Unique Key:
- Primary Key: Cannot have NULL values.
- Unique Key: Can have one NULL value.
Q12. Constraints in SQL:
Constraints are rules applied to columns to maintain data integrity.
Examples: PRIMARY KEY, NOT NULL, UNIQUE, CHECK.
Q13.
DDL command example: CREATE TABLE Students (...);
DML command example: INSERT INTO Students VALUES (...);
Q14. Reasons databases are preferred over file systems:
- Better data security
- Reduced data redundancy
Q15. Use of WHERE clause:
Used to filter rows based on a condition.
Example: SELECT * FROM Students WHERE City = 'Delhi';
Q16. SQL command to create table COURSE:
CREATE TABLE COURSE (
CID INT PRIMARY KEY,
CName VARCHAR(30),
Duration INT,
Fees INT
);
Q17. SALES table queries:
a) INSERT INTO SALES VALUES (401, 'Keyboard', 1800, 'June');
b) UPDATE SALES SET Amount = 2500 WHERE SaleID = 301;
c) DELETE FROM SALES WHERE Month = 'April';
Q18. Definitions:
Cardinality: Number of rows in a table.
Degree: Number of columns in a table.
Relation: A table in RDBMS.
Q19. SQL numeric data types:
INT, DECIMAL(5,2), FLOAT.
Q20. COURSE & DEPARTMENT:
a) Foreign key: DeptID in COURSE.
b) Primary keys: CourseID, DeptID.
c) SELECT CourseName, Fees FROM COURSE WHERE DeptID = 10;
d) SELECT * FROM COURSE WHERE Duration BETWEEN 6 AND 12;
Q21. PRODUCT table queries:
a) UPDATE PRODUCT SET Price = Price + (Price * 0.10) WHERE Category = 'Stationery';
b) SELECT PName FROM PRODUCT WHERE Price > 50;
c) ALTER TABLE PRODUCT ADD Supplier VARCHAR(30);
d) DELETE FROM PRODUCT WHERE PID = 303;