Sollicitatievraag bij Mphasis

SQL: Subqueries: Explain what a subquery is and provide an example of how you might use it. Normalization: What is database normalization, and why is it important? Can you give an example of normalization? Transactions: Describe the properties of a transaction in a database. What is ACID, and why is it important? Performance Tuning: How would you optimize a slow-performing SQL query? What tools or techniques would you use? Joins: Explain the differences between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.

Antwoord op sollicitatievraag

Anoniem

6 dec 2023

Normalization: Database normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. It involves dividing large tables into smaller, related tables and defining relationships between them. Normalization is essential for avoiding data anomalies and ensuring that modifications to the database are efficient. An example of normalization would be breaking a single table containing both employee information and department information into two separate tables, one for employees and one for departments, linked by a common key like department_id. Transactions: A transaction in a database is a set of one or more SQL statements that are executed as a single unit. Transactions must follow the ACID properties: Atomicity: All or nothing. Either all the changes in the transaction are executed, or none of them. Consistency: The database is in a consistent state before and after the transaction. Isolation: The changes made in a transaction are not visible to other transactions until the transaction is committed. Durability: Once a transaction is committed, its changes are permanent and survive future system failures. Performance Tuning: To optimize a slow-performing SQL query, you can consider several techniques: Indexing: Ensure that the columns involved in the WHERE clause or join conditions are indexed. Query Rewriting: Simplify complex queries or break them into smaller, more manageable ones. Database Schema Optimization: Evaluate and optimize the database schema for better performance. Use of Stored Procedures: Precompiled and optimized queries can improve performance. Update Statistics: Ensure that database statistics are up to date. Tools like SQL Profilers and Execution Plans can be useful for identifying bottlenecks and optimizing queries. Joins: INNER JOIN: Returns only the rows where there is a match in both tables based on the join condition. LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left table and matching rows from the right table. If there is no match, NULL values are returned for columns from the right table. RIGHT JOIN (or RIGHT OUTER JOIN): Returns all rows from the right table and matching rows from the left table. If there is no match, NULL values are returned for columns from the left table. FULL JOIN (or FULL OUTER JOIN): Returns all rows when there is a match in either the left or right table. If there is no match, NULL values are returned for columns from the table without a match.