Architecture: Concepts & Models البنية (Architecture): المفاهيم والنماذج
Exploring the Three-Schema Architecture, Data Independence, and the evolution of Data Models from Hierarchical to Relational. استكشاف معمارية المخططات الثلاثة (Three-Schema Architecture)، واستقلالية البيانات، وتطور نماذج البيانات من الهرمية إلى العلائقية.
Data Models Data Models (نماذج البيانات)
A Data Model is a set of concepts to describe the structure of a database, operations for manipulating data, and constraints. Data Model هو مجموعة من المفاهيم لوصف هيكل قاعدة البيانات، والعمليات لمعالجة البيانات، والقيود (Constraints).
1. Conceptual 1. Conceptual (المفاهيمي)
High-level, Semantic. Close to how users perceive data.
Example: Entity-Relationship Model.
عالي المستوى، دلالي (Semantic). قريب من كيفية إدراك المستخدمين للبيانات.
مثال: نموذج الكيان والعلاقة (ER Model).
2. Physical 2. Physical (المادي)
Low-level, Internal. Describes how data is stored in the computer (bits, tracks).
Example: Record formats, ordering.
منخفض المستوى، داخلي. يصف كيف يتم تخزين البيانات في الحاسوب (البتات، المسارات).
مثال: تنسيقات السجلات، الترتيب.
3. Implementation 3. Implementation (التنفيذي)
Representational. Falls between the two. Used by commercial DBMSs.
Example: Relational Data Model.
تمثيلي (Representational). يقع بين النوعين السابقين. يُستخدم بواسطة أنظمة إدارة قواعد البيانات التجارية.
مثال: نموذج البيانات العلائقي (Relational Model).
Schema vs. State Schema vs. State
Database Schema (Intension) Database Schema (Intension)
The description of the database. Includes structure, types, and constraints. Changes very infrequently. وصف قاعدة البيانات. يشمل الهيكل، والأنواع، والقيود. يتغير بشكل نادر جداً.
Database State (Extension) Database State (Extension)
The actual data stored at a particular moment. Changes every time the database is updated (Snapshot). البيانات الفعلية المخزنة في لحظة معينة. تتغير في كل مرة يتم فيها تحديث قاعدة البيانات (Snapshot).
Schema = Blueprint
State = The House content
Schema = المخطط الهندسي (Blueprint)
State = محتويات المنزل
Three-Schema Architecture Three-Schema Architecture
Logical Data Independence Logical Data Independence
Capacity to change the Conceptual Schema without changing External Schemas or Application Programs. القدرة على تغيير Conceptual Schema دون تغيير المخططات الخارجية (External Schemas) أو البرامج التطبيقية.
Physical Data Independence Physical Data Independence
Capacity to change the Internal Schema without changing the Conceptual Schema (e.g., creating a new index to improve performance). القدرة على تغيير Internal Schema دون تغيير الـ Conceptual Schema (مثلاً: إنشاء فهرس جديد لتحسين الأداء).
Languages & Interfaces Languages & Interfaces
DDL (Data Definition Language) DDL (لغة تعريف البيانات)
- Used by DBA and designers. تستخدم من قبل الـ DBA والمصممين.
- Specifies the conceptual schema. تحدد المخطط المفاهيمي (Conceptual Schema).
- Examples: `CREATE TABLE`, `ALTER`. أمثلة: `CREATE TABLE`, `ALTER`.
DML (Data Manipulation Language) DML (لغة معالجة البيانات)
- Used for retrieval, insertion, deletion, and updates. تستخدم للاسترجاع، والإدراج، والحذف، والتحديث.
- High-Level (Declarative): "What" to get (SQL). عالية المستوى (تصريحية): "ماذا" تريد (SQL).
- Low-Level (Procedural): "How" to get it (Record-at-a-time). منخفضة المستوى (إجرائية): "كيف" تحصل عليه (سجل تلو الآخر).
The Exam Vault خزنة الاختبار
Professor's Secrets & Trap Avoidance أسرار البروفيسور وتجنب الفخاخ
TRAP: Logical vs Physical Independence فخ: الاستقلالية المنطقية vs المادية
Physical Independence is changing the internal schema (e.g., adding an index) without breaking the conceptual schema.
Logical Independence is changing the conceptual schema (e.g., adding a column) without breaking external views/apps.
Hint: Logical is harder to achieve.
Physical Independence هو تغيير المخطط الداخلي (مثل إضافة فهرس) دون كسر المخطط المفاهيمي.
Logical Independence هو تغيير المخطط المفاهيمي (مثل إضافة عمود) دون كسر الـ Views الخارجية أو التطبيقات.
تلميح: تحقيقه أصعب.
TRAP: Schema vs State فخ: Schema vs State
If the question asks "Which of these changes frequently?", the answer is State (Extension). The Schema (Intension) changes rarely. إذا سأل السؤال "أي منهما يتغير بشكل متكرر؟"، الإجابة هي State (Extension). أما الـ Schema (Intension) تتغير نادراً.
SECRET: 3-Schema Purpose سر: هدف الـ 3-Schema
The main goal of the Three-Schema Architecture is Data Independence (Insulation between programs and data). It allows you to change the "plumbing" without rebuilding the house. الهدف الرئيسي لمعمارية الـ Three-Schema هو Data Independence (العزل بين البرامج والبيانات). فهي تسمح لك بتغيير "السباكة" دون إعادة بناء المنزل.
KEY CONCEPT: DDL vs DML مفهوم أساسي: DDL vs DML
DDL = Definition (Structure, Tables, Indexes).
DML = Manipulation (Select, Insert, Update, Delete).
Remember: DDL builds the bucket; DML fills it with water.
DDL = تعريف (الهيكل، الجداول، الفهارس).
DML = معالجة (Select, Insert, Update, Delete).
تذكر: DDL يبني الدلو؛ و DML يملؤه بالماء.