SQL Revision Questions with Answers 2024
SQL Revision Questions with Answers 2024
3. Give the details of Flight table with its schema for the Airlines company.
Flight Table Schema:
- Flight_ID: `Char(5)`
- Source: `Varchar(20)`
- Destination: `Varchar(20)`
- Departure_Time: `Time`
- Arrival_Time: `Time`
- Flight_Date: `Date`
5. ______ command displays all the tables created in the current database.
SHOW TABLES.
10. Which of the following constraints specifies that the value of every attribute
in each tuple must be from the domain of that attribute?
(a) Domain Constraint.
11. Database can be removed by using ____________ command.
DROP DATABASE command.
14. The functions that are used to apply certain mathematical functions on a
group of values in a database are called __________.
Aggregate functions.
18. Discuss any three main purposes of using database applications in the
education domain.
1. Managing student records and grades.
2. Library database management.
3. Scheduling classes and events.
19. Rectify the query: SELECT NAME, MARKS FROM STUDENT TABLE
WHERE NAME = 'P%';
Correct Query: `SELECT NAME, MARKS FROM STUDENT WHERE
NAME LIKE 'P%';`
27. Identify the Primary Key in Payment Table with columns Payment_id,
Payment_amount, Payment_date, Mode.
Primary Key: Payment_id.
28. Write SQL command to create the Gadget table with the specified schema.
CREATE TABLE Gadget (
G_ID CHAR(4),
Description VARCHAR(20),
Manufacture_Date DATE,
Price DECIMAL,
Warranty INT
);
29. Suggest datatypes for the following columns of Salary table: Emp_ID,
Name, Basic Salary, HRA, DateofJoin, Net_Salary.
- Emp_ID: INT
- Name: VARCHAR(50)
- Basic Salary: DECIMAL(10,2)
- HRA: DECIMAL(10,2)
- DateofJoin: DATE
- Net_Salary: DECIMAL(10,2)
30. Write any three domain names where database applications may be used
and examples.
1. Education: Student Management System.
2. Banking: Online Transaction System.
3. Retail: Inventory Management System.
31. Explain Referential Integrity Constraint with an example.
Referential Integrity ensures that a foreign key value must match a primary
key value in the referenced table.
Example: A foreign key `Customer_ID` in the `Orders` table must match the
`Customer_ID` in the `Customers` table.
35. Cardinality is four and degree is three. Add two columns and four rows.
What is the new degree and cardinality?
Degree: 5, Cardinality: 8.
37. What should be the datatype and size of the column price for 999.99?
Datatype: DECIMAL(6,2).
42. Once the database is created, you can check it in the list of databases that
currently exist on the server by using ___________ command.
SHOW DATABASES.
43. Write MySQL statement that selects all products with a price between 10
and 20 from the product table.
SELECT * FROM product WHERE price BETWEEN 10 AND 20;
46. (a) Find errors in query: SELECT * FROM employee WHERE name
LIKE *s;
Correct Query: `SELECT * FROM employee WHERE name LIKE 's%';`