DBMS
DBMS
Explore
#Google Interview
Show More
United States
credits:r/ProgrammerHumor
1. What is a DBMS?
Answer: A DBMS is software that manages databases, providing an interface to store, retrieve, and manipulate data efficiently
and securely.
15. What is the difference between a heap table and a clustered table?
Answer: A heap table does not have a clustered index, while a clustered table stores data physically sorted based on the
indexed column.
20. What are the advantages of using a NoSQL database over an RDBMS?
Answer: NoSQL databases offer flexibility, scalability, and better performance for unstructured or semi-structured data
compared to traditional RDBMS.
Bonus Questions:
2. What are the advantages and disadvantages of using stored procedures in a DBMS?
Answer: Advantages of stored procedures include improved performance (as they are precompiled), reduced network
traffic (since the code resides on the server), and enhanced security (as users only need execute permissions). However,
disadvantages include increased complexity and maintenance overhead, limited portability across different database
systems, and a potential lack of direct debugging capabilities.
3. What are the different types of locks in a DBMS, and how do they affect data concurrency?
Answer: The main types of locks are:
Shared Lock (Read Lock): Allows multiple transactions to read data simultaneously but not modify it.
Exclusive Lock (Write Lock): Only one transaction can acquire this lock, preventing other transactions from reading or
writing the locked data.
Update Lock: A hybrid lock that allows multiple transactions to read the data but prevents concurrent updates.
Intent Lock: Indicates that a transaction intends to acquire a higher-level lock to protect a range of data.
Locks play a vital role in managing data concurrency. Shared locks promote data read consistency, allowing multiple
transactions to read the same data simultaneously. Exclusive locks ensure data integrity by preventing multiple
transactions from modifying the same data simultaneously. However, excessive or poorly managed locks can lead to
contention and performance issues, impacting the overall database performance. Proper lock management and lock
escalation techniques are essential for efficient data concurrency control.
Epilogue:
GROUP BY and ORDER BY are two distinct clauses used in SQL for different purposes:
GROUP BY:
Example:
ORDER BY:
ORDER BY is used to sort the result set based on one or more columns.
It does not group rows but rather rearranges the rows in the output based on the specified sort criteria.
By default, ORDER BY sorts the result in ascending order. You can use the DESC keyword to sort in descending order.
Example:
In summary, GROUP BY is used for aggregation and dividing rows into groups, while ORDER BY is used for sorting the result set
based on specified columns.
A view is a virtual table that is derived from one or more base tables or other views. It does not store any data itself but
represents a tailored, pre-defined query that simplifies data retrieval. Views act as a layer of abstraction over the underlying
tables, providing a more user-friendly and secure way to interact with the data.
Data Abstraction: Views allow users to work with a simplified representation of the data, hiding unnecessary details and
complexity.
Security: Views can be used to restrict access to certain columns or rows, providing a level of security by only showing
specific data to specific users.
Simplified Querying: Complex queries can be encapsulated within views, making it easier for users to retrieve the desired
information without writing complex SQL statements.
Data Independence: If the underlying schema changes, views can remain the same, and applications using the views will
not be affected.
Contribution by @atroboyhimanshu
Q9 - Are NoSQL Databases always relational? Do they never follow ACID Properties?
Ans - False. NoSql databases can store relational Data. MongoDB supports ACID Transactions, unlike other NoSQL Databases.