ビューの更新は、顧客テーブルに挿入または更新される、新しく取り込まれたすべてのデータの増分バッチを表します。 これらのレコードを処理するには、次のロジックが使用されます。 顧客との融合 USING ( SELECT updates.customer_id as merge_ey, updates .* FROM updates UNION ALL SELECT NULL as merge_key, updates .* FROM updates JOIN customers オン updates.customer_id = 顧客.customer_id WHERE customers.current = true AND updates.address <> customers.address ) staged_updates ON customers.customer_id = mergekey WHEN MATCHED AND customers. current = true AND customers.address <> staged_updates.address THEN UPDATE SET current = false, end_date = staged_updates.effective_date WHEN NOT MATCHED THEN INSERT (customer_id, address, current, effective_date, end_date) VALUES (staged_updates.customer_id, staged_updates.address, true, staged_updates.effective_date, null) どのステートメントがこの実装について説明していますか?
正解:C
The provided MERGE statement is a classic implementation of a Type 2 SCD in a data warehousing context. In this approach, historical data is preserved by keeping old records (marking them as not current) and adding new records for changes. Specifically, when a match is found and there's a change in the address, the existing record in the customers table is updated to mark it as no longer current (current = false), and an end date is assigned (end_date = staged_updates.effective_date). A new record for the customer is then inserted with the updated information, marked as current. This method ensures that the full history of changes to customer information is maintained in the table, allowing for time-based analysis of customer data.