ASSIGNMENT
GRADE – 7
1. What is a database?
Ans: A database is an organized collection of information that allows for efficient data access, retrieval, and
management.
2. What is a Database Management System (DBMS)?
Ans: A DBMS is computer software that provides an interface between users and databases. It is software
designed to allow the creation, querying, updating, and administration of databases.
3. What is MySQL?
Ans: MySQL is an open-source relational database management system (RDBMS) that uses SQL (Structured
Query Language) for database operations.
4. What are the types of SQL statements, and how are they used in database management?
Ans: SQL (Structured Query Language) statements are categorized into three main types:
Data Definition Language (DDL): DDL statements are used to define and manage database objects such as
databases, tables, and indexes. Common DDL commands include CREATE, ALTER, DROP, and
TRUNCATE.
Data Manipulation Language (DML): DML statements are used to manipulate data within database
objects. Common DML commands include SELECT, INSERT, UPDATE, and DELETE.
Data Control Language (DCL): DCL statements are used to control access to data in the database.
Common DCL commands include GRANT and REVOKE.
5. What is the difference between DELETE, and TRUNCATE in SQL?
Ans:
DELETE: The DELETE statement is used to remove specific rows from a table based on a condition. It
can be rolled back and generates individual delete operations for each rows.
TRUNCATE: TRUNCATE, on the other hand, is used to remove all rows from a table. It cannot be
rolled back, and it is faster than DELETE as it deallocates the data pages instead of logging individual row
deletions.
6. What are the different categories of data types in MySQL?
Ans:
Text
Number
Date
7. What is the difference between CHAR and VARCHAR?
Ans: CHAR stores a fixed-length string (up to 255 characters), while VARCHAR stores a variable-length
string (also up to 255 characters by default).
8. Provide an example of how to create a table with a ‘PRIMARY KEY’.
Ans:
CREATE TABLE person (
person_id INT AUTO_INCREMENT,
name VARCHAR(100),
age INT,
PRIMARY KEY (person_id)
);
9. What is the purpose of defining a data type for a column in a database table?
Ans: The data type defines the operations that can be done directly on the data. For example, if a column is
defined as an integer, you can perform arithmetic operations like summing the data.
10. Explain the difference between CHAR and VARCHAR data types in MySQL, including their use cases
and limitations.
Ans: CHAR and VARCHAR are both used to store string data in MySQL, but they have key differences.
CHAR is used to store fixed-length strings. If you define a column as CHAR(10), it will always take up 10
bytes of storage, even if the string is shorter. This can be useful for storing data where the length is uniform,
such as fixed-length codes. On the other hand, VARCHAR is used to store variable-length strings. If you
define a column as VARCHAR(10), it will only use as much storage as necessary for the string, plus one byte
for the length (two bytes if the maximum length is more than 255). This makes VARCHAR more space-
efficient for storing strings of varying lengths.