0% found this document useful (0 votes)
26 views

SQL Revision Questions with Answers 2024

Uploaded by

ssss23232023
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

SQL Revision Questions with Answers 2024

Uploaded by

ssss23232023
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SQL Revision Questions with Answers

1. Write the use of database management in Railways.


Database management is used for ticket reservations, train schedules,
passenger details, and freight logistics.

2. How are database management concepts helpful in Telecommunications?


It helps manage customer records, billing details, call logs, and network data
efficiently.

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`

4. Why are database applications used in hospitals?


For managing patient records, appointments, billing, and inventory.

5. ______ command displays all the tables created in the current database.
SHOW TABLES.

6. _______ symbol replaces a single character while matching a pattern with


LIKE keyword.
The underscore (_) symbol.

7. Rectify the query: SELECT * FROM PRODUCT SORT BY PRICE;


Correct Query: `SELECT * FROM PRODUCT ORDER BY PRICE;`

8. The _________ command is used to view the structure and description of a


table.
DESCRIBE command.

9. Define Referential Integrity.


Ensures relationships between tables remain consistent by matching foreign
keys with primary keys in referenced 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.

12. Create Table is a __________ command.


DDL (Data Definition Language) command.

13. RDBMS packages are widely used as ______ (Frontend/Backend).


Backend.

14. The functions that are used to apply certain mathematical functions on a
group of values in a database are called __________.
Aggregate functions.

15. Mention any two major significances of Database Management System.


1. Efficient data retrieval.
2. Reduces redundancy and ensures consistency.

16. The number of attributes in a relation is called the __________ of a


relation.
Degree.

17. To avoid repetition in the result of a SELECT Query _________ clause is


used.
DISTINCT clause.

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%';`

20. Define Data.


Data is raw facts and figures that can be processed into meaningful
information.

21. The number of attributes in a relation is called its __________.


(a) Degree.

22. __________ is a set of attributes in a relation, for which no two tuples in a


relation state have the same combination of values.
Candidate Key.

23. In SQL, a column definition can be changed with the help of


____________ command.
ALTER TABLE command.

24. In SQL, while applying condition on a group, instead of WHERE clause


________ clause is used.
HAVING clause.

25. Name any two aggregate functions used in SQL.


1. SUM
2. AVG

26. ___________ command displays a list of databases available on the current


server.
SHOW DATABASES.

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.

32. SQL commands for the Menu table tasks:


(i) `SELECT * FROM Menu;`
(ii) `UPDATE Menu SET Price = Price + 10;`
(iii) `SELECT Description, Price FROM Menu ORDER BY Price ASC;`
(iv) `DESCRIBE Menu;`

33. Name two domains where database management may be used.


1. Healthcare.
2. E-commerce.

34. List any two advantages of DBMS.


1. Reduces data redundancy.
2. Facilitates data sharing.

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.

36. Correct the command: SELECT marks FROM teacher;


Correct command: `SELECT DISTINCT marks FROM teacher;`

37. What should be the datatype and size of the column price for 999.99?
Datatype: DECIMAL(6,2).

38. MySQL command to list teacher names in alphabetical order:


`SELECT * FROM teacher ORDER BY name;`

39. Schema for Shipment Table:


- Shipment_ID: INT
- Item_Code: CHAR(5)
- Destination: VARCHAR(20)
- Shipping_Date: DATE

40. Characteristics of Relational Model and aggregate function for average:


1. Data stored in tables.
2. Integrity constraints supported.
Aggregate Function: AVG.

41. SQL Commands for TRAIN and COUNTER tables:


(a) `SELECT Station, Date FROM COUNTER WHERE TicketID = 'T1';`
(b) `SELECT Station, SUM(Cost) FROM COUNTER GROUP BY Station;
(c) `SHOW TABLES;`
(d) `DROP TABLE COUNTER;`

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;

44. Reema wants to arrange names of students in alphabetical order in the


student table.
Query: `SELECT * FROM student ORDER BY name ASC;`

45. Explain any two operations performed on a database.


1. Insert: Adds new records to a table.
Example: `INSERT INTO student (id, name) VALUES (1, 'John');`
2. Update: Modifies existing records.
Example: `UPDATE student SET name = 'Jane' WHERE id = 1;`

46. (a) Find errors in query: SELECT * FROM employee WHERE name
LIKE *s;
Correct Query: `SELECT * FROM employee WHERE name LIKE 's%';`

(b) Classify into DDL or DML commands:


- Update, Delete: DML
- Create, Alter: DDL

47. SQL Commands for STORE and OWNER tables:


a) To display the number of employees in each location:
SELECT Location, SUM(NoOfEmployee) AS TotalEmployees FROM
STORE GROUP BY Location;
b) To display Store names, Location, and Date of Opening of stores opened
before 2015:
SELECT StoreName, Location, OpeningYear FROM STORE WHERE
OpeningYear < 2015;
c) To add a new column SALE of integer type:
ALTER TABLE STORE ADD Sale INT;
d) To display Store Name and Owner Name of all stores in Mumbai:
SELECT StoreName, OwnerName FROM STORE, OWNER
WHERE STORE.OwnerId = OWNER.OwnerId AND Location = 'Mumbai';

You might also like