Which caching strategy is suitable for reducing database load and improving response times for frequently accessed data?
- Browser Caching
- Content Delivery Network (CDN) Caching
- Database Caching
- Object Caching
Database Caching is a caching strategy suitable for reducing database load and improving response times for frequently accessed data. It involves storing query results or data in memory to avoid repeated database queries for the same data.
In RESTful APIs, _______ is a mechanism used to control access to resources.
- Authentication
- Authorization
- Decryption
- Encryption
In RESTful APIs, Authorization is a mechanism used to control access to resources. It determines whether the authenticated user has the necessary permissions to perform a particular action on a resource.
A stored procedure is _______ in a relational database, which can be executed by invoking its name.
- a precompiled collection of one or more SQL statements
- a temporary table
- a trigger
- an index
A stored procedure in a relational database is a precompiled collection of one or more SQL statements. It is stored as a database object and can be executed by invoking its name.
Imagine a scenario where two users are trying to update the same record in a database concurrently. Describe the potential issues that may arise and propose a concurrency control strategy to address them.
- Issues: Deadlocks, Race Conditions
- Issues: Lost Updates, Inconsistent Data
- Strategy: Apply Pessimistic Locking
- Strategy: Use Timestamps for Versioning
Concurrent updates on the same database record may lead to issues such as lost updates and inconsistent data. Using timestamps for versioning is a strategy to address this, allowing the system to track and compare versions to ensure updates occur in a controlled and consistent manner, reducing conflicts.
In SQL, the ALTER TABLE command is used to _______ an existing database table.
- Add
- Delete
- Modify
- Update
The ALTER TABLE command in SQL is used to modify an existing database table. It allows you to add, delete, or modify columns and constraints of a table.
In database management, what is cardinality, and how does it impact query optimization?
- The number of rows in a table
- The relationship between tables
- The size of the database
- The uniqueness of values in a column
Cardinality in database management refers to the relationship between tables. It impacts query optimization by influencing the choice of join algorithms and the order in which tables are accessed, crucial for performance.
You encounter a bug in your codebase. How would you use TDD principles to fix it and prevent similar issues in the future?
- Fix the bug directly without writing tests
- Ignore the bug and focus on adding new features
- Write a failing test that reproduces the bug, fix the bug, and ensure the test passes
- Write tests for unrelated features to cover more code paths
Using TDD to fix a bug involves writing a failing test that reproduces the issue, then fixing the bug to make the test pass. This ensures that the bug is addressed and helps prevent regressions by having a test in place.
In a project, you have a table with millions of records, and your queries are taking too long to execute. What strategies would you employ to optimize the performance of the database?
- Indexing and Query Optimization
- Denormalization and Partitioning
- Caching and Replication
- Sharding and Vertical Scaling
To optimize the performance of a database with millions of records, strategies such as indexing, query optimization, denormalization, partitioning, caching, and replication can be employed. The correct option focuses on indexing and query optimization.
Which HTTP method is typically used for creating a new resource in a RESTful API?
- DELETE
- GET
- POST
- PUT
The HTTP method used for creating a new resource in a RESTful API is POST. It submits data to be processed to a specified resource.
What is the role of alerting in a monitoring system?
- Archive historical data
- Display real-time data
- Generate reports
- Notify stakeholders about abnormal conditions
The primary role of alerting in a monitoring system is to notify stakeholders about abnormal conditions or events. Alerts enable timely responses to issues, helping in proactive troubleshooting and maintaining system reliability.