Midterm Knowledge Compendium المراجعة الشاملة للاختبار النصفي

A complete synthesis of Modules 1 through 6. From the basics of Data Models to the complexities of EER Mapping. ملخص كامل للوحدات من 1 إلى 6. من أساسيات نماذج البيانات إلى تعقيدات تحويل المخطط (EER Mapping).

Covering Modules 1-6 تغطية الوحدات 1-6


01. Foundations 01. الأساسيات

Definitions تعريفات

Core Concepts المفاهيم الجوهرية

  • Database (DB): Database (DB): Collection of related data representing a Miniworld. مجموعة من البيانات المرتبطة تمثل Miniworld.
  • DBMS: DBMS: Software to define, construct, and manipulate the DB. برمجيات لتعريف، وبناء، ومعالجة قاعدة البيانات.
  • Meta-data: Meta-data: "Data about Data" (Structure, Constraints). Stored in the Catalog. "بيانات عن البيانات" (الهيكل، القيود). تخزن في الكتالوج.

Key Advantages مزايا رئيسية

Program-Data Independence:Program-Data Independence: Changing data structure (e.g., adding a field) does NOT require rewriting applications. The DBMS handles the mapping. تغيير هيكل البيانات (مثل إضافة حقل) لا يتطلب إعادة كتابة التطبيقات. الـ DBMS يتولى عملية الربط.

02. Architecture 02. البنية (Architecture)

3-Schema 3-Schema

The Three Schemas المخططات الثلاثة

  • 1. Internal:1. Internal: Physical storage (Bits, Indices). التخزين المادي (Bits, Indices).
  • 2. Conceptual:2. Conceptual: Structure (Entities, Relationships). Hides storage details. الهيكل (Entities, Relationships). يخفي تفاصيل التخزين.
  • 3. External:3. External: User Views (Subsets of data). وجهات نظر المستخدم (مجموعات فرعية من البيانات).

Data Independence استقلالية البيانات (Data Independence)

Logical Logical Change Conceptual w/o breaking External views. تغيير الـ Conceptual دون كسر الـ External views.
Physical Physical Change Internal (Optimization) w/o breaking Conceptual. تغيير الـ Internal (تحسين) دون كسر الـ Conceptual.

03. Relational Model 03. النموذج العلائقي

Tables & Constraints Tables & Constraints

Keys المفاتيح (Keys)

  • Superkey:Superkey: Unique identifier (can be redundant). معرف فريد (قد يحتوي على تكرار).
  • Candidate Key:Candidate Key: Minimal Superkey. Minimal Superkey.
  • Primary Key (PK):Primary Key (PK): Chosen Candidate Key. Cannot be NULL. المفتاح المرشح المختار. لا يمكن أن يكون NULL.

Integrity Constraints قيود التكامل

  • Entity Integrity:Entity Integrity: PK $\neq$ NULL. PK $\neq$ NULL.
  • Referential Integrity:Referential Integrity: Foreign Key (FK) must match an existing PK in the referenced table OR be NULL. Foreign Key (FK) يجب أن يطابق PK موجود في الجدول المشار إليه أو يكون NULL.

04. ER Modeling 04. نمذجة ER

Concepts Concepts

Attributes السمات (Attributes)

Simple Composite (Address) Multi-valued (Color) { } Derived (Age)

Weak Entity Weak Entity

Has no Key. Identified by an Owner Entity via an Identifying Relationship. لا يملك مفتاحاً. يُعرف بواسطة Owner Entity عبر علاقة تعريف.
Example: Dependent relies on Employee. مثال: التابع (Dependent) يعتمد على الموظف (Employee).

05. EER Inheritance 05. وراثة EER

Super/Subclass Super/Subclass

Specialization vs Generalization Specialization vs Generalization

  • Specialization (Top-Down):Specialization (من أعلى لأسفل): Breaking Entity into subgroups (Employee $\to$ Secretary, Engineer). تقسيم الكيان إلى مجموعات فرعية (Employee $\to$ Secretary, Engineer).
  • Generalization (Bottom-Up):Generalization (من أسفل لأعلى): Combining entities into a superclass (Car, Truck $\to$ Vehicle). دمج الكيانات في superclass واحد (Car, Truck $\to$ Vehicle).

Inheritance الوراثة (Inheritance)

Subclasses inherit ALL attributes and relationships of the Superclass. ترث الـ Subclasses جميع سمات وعلاقات الـ Superclass.

06. Mapping & Constraints 06. التحويل والقيود

Logical Design التصميم المنطقي

Constraint Types أنواع القيود

Disjoint (d):Disjoint (d): Overlap NOT allowed. التداخل غير مسموح.
Overlap (o):Overlap (o): Entity can be in multiple subclasses. الكيان يمكن أن يكون في أكثر من subclass.
Total (Double):Total (مزدوج): Every Super must be a Sub. كل Super يجب أن يكون Sub.
Partial (Single):Partial (مفرد): Super can exist alone. Super يمكن أن يوجد وحده.
Union Type (Category) Union Type (Category)

A subclass with multiple superclasses representing different entity types. Relation is OR.
(e.g., Owner is Person OR Bank OR Company).
Subclass مع superclasses متعددة تمثل أنواع كيانات مختلفة. العلاقة هي OR.
(مثال: المالك هو شخص أو بنك أو شركة).

The 7-Step Mapping Algorithm خوارزمية التحويل ذات الـ 7 خطوات

Step 1: Strong Step 1: Strong Create table. Simple attributes become columns. أنشئ جدولاً. السمات البسيطة تصبح أعمدة.
Step 2: Weak Step 2: Weak Create table. Add Owner PK as FK.
PK = {OwnerPK + PartialKey}.
أنشئ جدولاً. أضف PK المالك كـ FK.
PK = {OwnerPK + PartialKey}.
Step 3: 1:1 Step 3: 1:1 Add PK of one side as FK to the other. Prefer Total Participation side. أضف PK لجانب واحد كـ FK للآخر. فضل الجانب ذو Total Participation.
Step 4: 1:N Step 4: 1:N Add PK of "1-side" as FK to "N-side". (Parent ID goes to Child). أضف PK لـ "جانب 1" كـ FK لـ "جانب N". (ID الأب يذهب للابن).
Step 5: M:N Step 5: M:N Create Associative Table. Include PKs of both sides as FKs. PK = {FK1, FK2}. أنشئ جدول ربط (Associative Table). ضمن PKs للجانبين كـ FKs. الـ PK = {FK1, FK2}.
Step 6: Multi-Val Step 6: Multi-Val Create new table. PK = {ParentID, Value}. أنشئ جدولاً جديداً. PK = {ParentID, Value}.
Step 7: N-ary Step 7: N-ary Create new table with FKs from all participating entities. أنشئ جدولاً جديداً مع FKs من جميع الكيانات المشاركة.

The Midterm Mega Vault خزنة الاختبار النصفية الكبرى

All Secrets, Traps, and Tricks (Mod 1-6) كل الأسرار، والفخاخ، والخدع (الوحدات 1-6)

TRAP: Schema vs State فخ: Schema vs State

Schema (Intension): The blueprint. Changes rarely.
State (Extension): The data content. Changes frequently. Don't confuse them!
Schema (Intension): المخطط. يتغير نادراً.
State (Extension): محتوى البيانات. يتغير بشكل متكرر. لا تخلط بينهم!

TRAP: 1:N Mapping فخ: 1:N Mapping

Never put the Foreign Key on the "1-side". It violates 1NF (atomic values).
Always put the FK on the N-side (the child).
لا تضع أبداً المفتاح الأجنبي (FK) في "جانب 1". هذا ينتهك 1NF (القيم الذرية).
دائماً ضع الـ FK في جانب N (الطفل).

TRAP: Weak Entity PK فخ: Weak Entity PK

A Weak Entity does NOT have a Primary Key of its own. It has a Partial Key. Its PK in the database is (Owner PK + Partial Key). الـ Weak Entity ليس لديه Primary Key خاص به. لديه Partial Key. الـ PK الخاص به في قاعدة البيانات هو (Owner PK + Partial Key).

SECRET: Meta-Data سر: Meta-Data

What makes a DBMS "Self-Describing"?
The existence of the System Catalog which stores the Meta-data (description of structure and constraints).
ما الذي يجعل الـ DBMS "يصف نفسه ذاتياً"؟
وجود System Catalog الذي يخزن الـ Meta-data (وصف الهيكل والقيود).

SECRET: Composite Attribute Mapping سر: Composite Attribute Mapping

When mapping a composite attribute (e.g., Address: City, Street), you do NOT create a separate table. You just flatten the components into columns (Address_City, Address_Street) in the main table. عند تحويل سمة مركبة (مثل العنوان: مدينة، شارع)، لا تنشئ جدولاً منفصلاً. فقط قم بتسطيح المكونات إلى أعمدة (Address_City, Address_Street) في الجدول الرئيسي.

SECRET: M:N Attributes سر: سمات M:N

If a relationship has an attribute (e.g., "Hours Worked"), and the relationship is M:N, that attribute belongs to the Associative Entity (the middle table), not the Employee or Project tables. إذا كان للعلاقة سمة (مثل "ساعات العمل")، والعلاقة هي M:N، فإن تلك السمة تنتمي إلى Associative Entity (الجدول الأوسط)، وليس جداول الموظف أو المشروع.