SQL Azure Interview Questions Guide
SQL Azure Interview Questions Guide
IaaS (Infrastructure as a Service) provides the highest level of control, where users manage the operating system, applications, and data. It's ideal for migrating legacy applications to the cloud. An example is Azure VMs . PaaS (Platform as a Service) offers a middle ground where the user manages applications and data while the provider handles operating systems. It suits developing new applications, such as using Azure App Service . SaaS (Software as a Service) provides the least control, offering fully managed software which users can subscribe to, suited for ready-to-use applications like Gmail or Salesforce . Each service model supports varying degrees of user responsibility and customization based on the desired level of management and integration.
Azure facilitates disaster recovery and fault tolerance primarily through Managed Disks with built-in redundancy and automatic replication across different data centers, ensuring data durability and accessibility in case of hardware failures . Managed services like Azure Backup and Site Recovery offer automated backup solutions and replication of workloads to secondary locations for quick restoration, and thus play a crucial role in business continuity planning. The use of distributed cloud environments minimizes the risk associated with localized failures and allows for more robust system availability. Additionally, features like Azure's SLA commitments provide assurance of uptime and service reliability.
In OLTP environments, which focus on real-time order processing and data transactions (e.g., e-commerce orders), ETL processes are typically less intensive and may operate in near-real-time to accommodate frequent small-scale data updates . In OLAP environments, which are optimized for analytical queries, ETL processes tend to be more elaborate, tasked with extracting large batches of data, transforming it to fit analytical models, and loading it into data warehouses for complex, historical analysis . The primary change between contexts is the frequency and complexity of the ETL operations, with OLAP requiring less frequent but more complex data transformations and loading operations focused on comprehensive data aggregation and preparation for analysis.
SQL subqueries enhance data retrieval by allowing additional queries within a main query, facilitating complex data filtering and aggregation without duplicating code . Scalar subqueries return a single value, often used in expressions where a single data point influences the larger query context. Single-row subqueries return only one row with multiple columns, useful for direct comparisons or settings where multiple values are retrieved but only one row is valid for execution context . Correlated subqueries, unlike their non-correlated counterparts, depend on an outer query's data for each row and offer in-depth, row-specific data manipulation, though they may impact performance due to repetitive execution per outer query row . Understanding these types allows for tailored query design that optimizes both readability and performance.
Normalization is the process of organizing a database to minimize redundancy by splitting a database into smaller tables and defining relationships between them, typically achieving efficiencies through 1NF to 5NF . Denormalization, conversely, adds redundancy to a database to optimize read performance, commonly used in data warehouses where query performance is prioritized . While normalization is beneficial in OLTP systems for handling transactional operations with small, frequent updates and inserts, denormalization is preferred in OLAP scenarios where complex queries require fast read access to large volumes of data.
Python supports multiple inheritance, allowing a class to inherit features from more than one parent class, a flexibility not present in many languages that limit a class to a single inheritance path . Benefits include enhanced modularity and code reuse, with the ability to incorporate methods and attributes from multiple sources, creating complex and feature-rich objects easily. However, it introduces complications such as the Diamond Problem, where inheritance paths might lead to ambiguous method resolutions and increased debugging difficulty due to entangled dependencies. Python addresses some of these issues with the Method Resolution Order (MRO), maintaining a clear path using the C3 superclass linearization.
INNER JOIN returns only matching rows from both tables, often used when absolute data consistency is needed across sources, and generally the most efficient join in terms of processing time and resource usage . LEFT JOIN returns all rows from the left table and the matched rows from the right table, adding NULLs for non-matching rows, suitable for when all left-side entries are required regardless of matches . RIGHT JOIN operates similarly, but keeps all right table rows, useful for preserving right-side data integrity . FULL JOIN returns all matching records from both tables, filling unmatched areas with NULLs, often used where comprehensive data reporting is needed but can be resource-intensive due to its broad scope. Selection of join types must consider balance between data completeness and query performance.
SCD Type 1 involves overwriting old data with new, thus no historical trace is kept, and is applicable when changes are irrelevant . SCD Type 2 retains historical changes by adding a new row each time a change occurs, providing a complete timeline and is suitable for systems requiring full historical data . SCD Type 3 tracks limited changes by updating existing data often using additional columns, which is useful for scenarios where only the latest and one previous version are relevant . For a system requiring comprehensive historical accuracy, SCD Type 2 would be the best choice as it maintains full historical records of data changes over time.
Star schema is a type of data warehouse schema characterized by denormalized, highly simplified tables which include fact tables with metrics linked to dimension tables with descriptive attributes . Snowflake schema, on the other hand, involves normalized dimension tables, and is more complex due to its hierarchical layout of tables . Star schemas are often favored in environments where query performance is critical and the complexity of data relationships is low, allowing quick insights with simpler joins. Snowflake schemas might be advantageous in scenarios with more complex analytical requirements, as they reduce redundancy and can lead to more accurate data representation, albeit with potentially slower read performance due to additional joins.
Logical operators in Python ('and', 'or', 'not') are essential in control flow for making multiple conditional checks more streamlined and efficient . The 'and' operator ensures that both conditions must be true for the overall expression to evaluate true, often used in series of dependent constraints. The 'or' operator provides flexibility, allowing either condition to suffice for a true evaluation, which is handy for alternative pathways in control flow. The 'not' operator inverts boolean values, crucial for toggling between states based on condition outcomes. Understanding these operators enables concise, readable, and optimized control structures, reducing redundancy and enhancing performance by short-circuiting unnecessary evaluations.