انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهMID-019-L02

أنماط إلغاء التطبيع

  • الدرس 2 من 6
  • Mid-level
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

apply a denormalization and keep copies consistent.

الموضوعات المخطط لها

  • Common patterns: a copied column (product_name in order_item as a historical snapshot), a counter (order_count), a summary table, a materialized view.
  • Historical snapshots (price at purchase) are not duplication: they are different facts.
  • Keep derived copies consistent with transactions, triggers, or periodic refresh; choose by how stale the data may be.
  • REFRESH MATERIALIZED VIEW CONCURRENTLY needs a unique index and avoids blocking readers.
  • Document who owns each copy and how it is repaired.
تفاصيل المخطط المبدئي

عرض عملي

sql
CREATE MATERIALIZED VIEW daily_sales AS
SELECT date_trunc('day', created_at) AS day, sum(total_cents) AS revenue
FROM orders GROUP BY 1;
CREATE UNIQUE INDEX ON daily_sales (day);
REFRESH MATERIALIZED VIEW CONCURRENTLY daily_sales;

اختبر فهمك

Why does price_cents in order_item belong there even in a normalized design?

أظهر الإجابة

It records the price at purchase time, which differs from the current price.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.