🌐 Detecting your location…
📢 Advertisement — Configure AdSense in Appearance → Customize → AdSense Settings

أسئلة مقابلة قاعدة البيانات 2026: SQL، والتطبيع، وACID، والمشاركة

⏱️3 min read  ·  464 words

تغطي أسئلة مقابلة قاعدة البيانات في عام 2026 أساسيات SQL، والمعاملات، والفهرسة، والتطبيع، وNoSQL vs SQL، وخدمات قواعد البيانات السحابية. يغطي هذا الدليل أسئلة قاعدة البيانات الأكثر شيوعًا لأدوار مطوري الواجهة الخلفية ومهندس البيانات.

أسئلة قاعدة البيانات الأساسية

1. ما هو التطبيع؟ شرح 1NF، 2NF، 3NF

Normalization: organize tables to reduce redundancy and improve integrity

1NF (First Normal Form):
  - Each column contains atomic (indivisible) values
  - No repeating groups or arrays in columns
  BAD:  users(id, name, phones="555-1234,555-5678")
  GOOD: users(id, name) + phones(id, user_id, phone)

2NF (Second Normal Form):
  - Must be in 1NF
  - All non-key columns depend on the ENTIRE primary key (no partial dependency)
  BAD:  orders(order_id, product_id, product_name, qty)
        product_name depends only on product_id, not full key
  GOOD: orders(order_id, product_id, qty)
        products(product_id, product_name)

3NF (Third Normal Form):
  - Must be in 2NF
  - No transitive dependencies (non-key columns depend only on key)
  BAD:  employees(emp_id, dept_id, dept_name)
        dept_name depends on dept_id, not emp_id
  GOOD: employees(emp_id, dept_id)
        departments(dept_id, dept_name)

2. ما هي خصائص الحمض؟

  • الذرية: المعاملة هي كل شيء أو لا شيء – تحويل 100 دولار: ينجح كل من الخصم والائتمان أو يفشل كلاهما
  • تناسق: تنتقل قاعدة البيانات من حالة صالحة إلى أخرى — ولا يمكن أن يكون الرصيد سلبيًا أبدًا
  • عزل: المعاملات المتزامنة لا تتداخل – لا ينجح مستخدمان يحجزان نفس المقعد
  • متانة: البيانات التي تم الالتزام بها تنجو من الأعطال – ويتم كتابتها على القرص، وليس الذاكرة فقط

3. شرح مستويات العزلة ومقايضاتها

-- Isolation levels (weakest to strongest):

-- READ UNCOMMITTED: can read uncommitted data (dirty reads)
-- Rarely used, maximum performance

-- READ COMMITTED (default in PostgreSQL):
-- Only reads committed data. Prevents dirty reads.
-- Non-repeatable reads possible (same query returns different results)

-- REPEATABLE READ (default in MySQL):
-- Same rows return same data within transaction.
-- Phantom reads possible (new rows can appear)

-- SERIALIZABLE: full isolation, no phantoms
-- Slowest, all transactions run as if sequential
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

-- In PostgreSQL
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
-- ...
COMMIT;

-- Common choice: READ COMMITTED for most apps
-- REPEATABLE READ for financial reporting
-- SERIALIZABLE for critical financial transactions

4. ما الفرق بين الفهارس المجمعة وغير المجمعة؟

  • مؤشر مجمع: صفوف البيانات المخزنة بترتيب الفهرس. واحد لكل طاولة. يستخدم InnoDB المفتاح الأساسي كمجمع.
  • غير متجمعة: هيكل منفصل يشير إلى صفوف البيانات. متعددة لكل جدول.

-- Clustered: physical order of data = index order
-- PRIMARY KEY automatically creates clustered index in most DBs
CREATE TABLE users (
  id BIGSERIAL PRIMARY KEY,  -- clustered index
  email VARCHAR(255),
  name VARCHAR(100)
);

-- Non-clustered: lookup structure → pointer to data
CREATE INDEX idx_email ON users(email);  -- non-clustered

-- Covering index: includes all needed columns
-- Allows index-only scan (never touches data pages)
CREATE INDEX idx_user_lookup ON users(email) INCLUDE (id, name);
-- SELECT id, name FROM users WHERE email = 'alice@example.com'
-- Can be answered entirely from index — very fast!

5. متى تختار NoSQL بدلاً من SQL؟

اختر SQL متى اختر NoSQL متى
العلاقات المعقدة (JOINs) أنماط الوصول البسيطة (قيمة المفتاح)
المعاملات ACID اللازمة نطاق واسع (التقسيم مطلوب)
الاستعلامات المعقدة والمجموعات مخطط مرن
البيانات المالية والمخزونية إنتاجية كتابة عالية
الفريق يعرف SQL وثائق JSON، البيانات المتداخلة

6. شرح تقسيم قاعدة البيانات

المشاركة: تقسيم البيانات أفقيًا عبر مثيلات قاعدة البيانات المتعددة.

Sharding strategies:

Range-based: shard by value range
  Shard 1: user_id 1-1M
  Shard 2: user_id 1M-2M
  Pros: range queries efficient
  Cons: hot spots (newest users all on last shard)

Hash-based: shard_num = hash(user_id) % num_shards
  Even distribution
  Cons: range queries hit all shards, resharding is hard

Directory-based: lookup table maps key → shard
  Flexible, easy to rebalance
  Cons: lookup overhead, single point of failure

Cross-shard challenges:
  - JOINs must be done in application layer
  - Distributed transactions are complex
  - Global uniqueness (use UUIDs instead of auto-increment)

تختبر مقابلات قاعدة البيانات اتساع نطاق (SQL، والتطبيع، وACID) والعمق (تحسين الاستعلام، واستراتيجية الفهرسة). تعرف على كيفية استخدام شرح التحليل، وافهم متى يساعد كل نوع من أنواع الفهرس، واشرح مقايضات التقسيم بوضوح. غالبًا ما تغطي أسئلة الإنتاج تجميع الاتصال وتأخر النسخ المتماثل ومعالجة استعلامات N+1.

✍️ Leave a Comment

Your email address will not be published. Required fields are marked *

🌐 Read in:🇬🇧 English🇩🇪 Deutsch🇧🇷 Português🇸🇦 العربية🇮🇳 हिन्दी🇧🇩 বাংলা