Database Questions and Answers| Question Answer of Database| DBMS Interview Question and Answer

1. What is a database?

Answer: A database is a collection of related data. It is an organized form of data for easy access, storing, retrieval and managing of data. It represents some aspects of the real world.

2. What is DBMS? Name two DBMS Software.

Answer: DBMS stands for Database Management System. It is a software that enables users to create and maintain databases. DBMS is used to store, manage, and retrieve data efficiently. The name of two DBMS are MySql and SQLite.

3. Define RDBMS.

Answer: RDBMS stands for Relational Database Management System. It is a database management system which is based on relational model.

4. Write the relationship between a database and a table.

Answer: A database contains multiple tables whereas, a table cannot exist outside a database.

5. What is the difference between ‘Rows’ and ‘Columns’ in a table?

Answer: In a table, rows are called records and columns are termed as fields or attributes. A row stores complete information of a record whereas column stores only similar data values for all records.

6. What is SQL?

Answer: SQL stands for Structured Query Language. It is a standard language for accessing and manipulating databases. SQL is used to communicate with a database. It is a database language used to create maintain and retrieve the relational database.

7. How many SQL statements are used? Define them.

Answer: SQL statements are basically divided into following categories-DDL, DML, DCL and TCL.

Data Definition Language (DDL) commands are used to define the structure that holds the data. DDL commands define or change the structure of the database. It includes adding, deleting, and changing tables and databases. Example: CREATE, ALTER, DROP

Data Manipulation Language (DML) commands are used to manipulate the data of the database. These commands are used for managing and manipulating data. Example: INSERT, DELETE, UPDATE, SELECT

Data Control Language (DCL) commands are used to control the visibility of the data in the database like revoke access permission for using data in the database. These commands used to regulate access, rights, and other aspects of the database system. Example: GRANT, REVOKE

Transaction Control Language (TCL) manages transactions in the database. Example: COMMIT, ROLLBACK AND SAVEPOINT

8. What is an SQL query?

    Ans: An SQL query is a command used to get data out of a database. In general terms, a query in SQL is a request to databases to fetch (or retrieve) the information. Queries are SQL commands used to interact with databases. 

    9. What is primary key? Give an example.

    Answer: A field which uniquely identifies each record in a table is known as primary key. e.g. RollNo is the primary key of the Student table.

    10. Give one advantage of using primary key.
    Answer: A primary key uniquely identifies the record in the table.

    11. What is a foreign Key?

    Answer: Foreign Key is used to establish relationships between two tables. It is a field in one table that refers to the primary key of another table. It is used to link two tables.

    12. Write the significance of a foreign key.

    Ans: A foreign key is used to Establish relationship between any two tables of RDBMS.

    13. Differentiate between DROP and DELETE.

    Answer: The DELETE command deletes one or more existing records from the table in the database. The DROP Command drops the complete table from the database.

    14. Write Full Form of following terms

    (i) SQL

    (ii) DDL

    (iii) DML

    (iv) DCL

    (v) DQL

    (vi) TCL

    (vii) DBMS

    (viii) RDBMS

    Answer:

    SQL: Structured Query Language

    DBA: Database Administrator

    DDL: Data Definition Language

    DML: Data Manipulation Language

    DCL: Data Control Language

    DQL: Data Query Language

    TCL: Transaction Control Language

    DBMS: Database Management System

    RDBMS: Relational Database Management System

    15. Which command is used to retrieve data from the table?

    Answer: Select command is used to retrieve data from the table.

    16. Write the Select command to display all the records of table “book”.

    Answer: Select * from book;

    17. What is the purpose of Order by clause in Select Command?

    Answer: Order by clause is used to arrange the records in ascending or descending order.

    18. What is the purpose of Where clause in Select Command?

     Answer: Where Clause is used to retrieve specific record from the table.

    19. Describe the difference between the HAVING and WHERE clause.

      Answer:

      WHERE Clause: Where clause filters rows. It applies conditions to individual records in the table(s) involved in the SQL statement. Where Clause is used to retrieve specific record from the table. The WHERE clause cannot be used with aggregate functions.

      HAVING Clause: The HAVING clause filters groups after applying the GROUP BY clause. It is often used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to filter the results of a GROUP BY operation.

      HAVING clause was added to SQL because the where keyword cannot be used with aggregate functions.

      In short, we can say,

      The WHERE clause filters data from individual rows in a table based on specified conditions, while the HAVING clause filters data from groups of rows in a query based on conditions involving aggregate values.

      20. What are aggregate functions?

      Answer: Aggregate functions are used to calculate values and return a single result. These functions include finding the number of items (COUNT), sum (SUM), average (AVG), minimum (MIN), or maximum (MAX) value in a column of a table.

      21. What are the Common SQL Functions Used for Data Aggregation?

      Answer:

      SUM(): Calculates the total sum of a numeric column.

      AVG(): Calculates the average value of a numeric column.

      COUNT(): Counts the number of rows that match a specified condition.

      MIN(): Finds the minimum value in a column.

      MAX(): Finds the maximum value in a column.

      22. What are savepoints in a transaction?

      Answer: Savepoints are special mark within a transaction that allow us to define points we can roll back without rolling back the entire transaction. They provide a way to divide a transaction into smaller units and selectively undo parts of the transaction if necessary.

      7 thoughts on “Database Questions and Answers| Question Answer of Database| DBMS Interview Question and Answer”

      1. This is very interesting, You are an excessively skilled blogger. I’ve joined your feed and sit up for looking for extra of your magnificent post. Additionally, I’ve shared your web site in my social networks!

        Reply

      Leave a Comment