التضمين مقابل المرجعية
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
decide where related data lives, based on access patterns.
الموضوعات المخطط لها
- Embed when data is read together, is owned by the parent, and stays bounded (an address inside an order).
- Reference when data is shared, large, changes on its own, or grows without limit (all reviews of a product).
- An unbounded array inside a document (reviews inside a product) is the classic mistake: documents grow, updates slow down, 16 MB limit.
- Copy small, stable fields (customer display name) into the document to avoid lookups; accept update cost.
- Do not copy a relational schema table by table.
تفاصيل المخطط المبدئي
عرض عملي
two options for reviews: embedded array in product (bad: unbounded) versus a reviews collection with productId (good), plus an embedded ratingSummary in product (small and bounded).
اختبر فهمك
Why not embed all reviews in the product document?
أظهر الإجابة
The array is unbounded: the document grows and every update is costly.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.