VWhen would you choose a relational database over a document store?
سؤال المقابلقواعد البيانات
تنتقل مقابلات قواعد البيانات عادةً من الأساسيات (SQL والربط joins والفهارس) إلى المعاملات والأداء. وفي الجزء الشفهي، المهارة الأهم هي شرح فكرة تقنية ببساطة دون رسمها على السبورة.
استخدم التباين لتجعل إجاباتك واضحة: «مع الفهرس تفعل قاعدة البيانات X، وبدونه تفعل Y». التباين سهل التذكر للمستمع، وسهل القول بالإنجليزية.
- ✓كلمات → عبارات → جمل → تحدث
- ✓معنى الإجابة
- ✓اللغة
أكثر الأسئلة تكرارًا ونماذج الإجابات
When would you choose a relational database over a document store?
متى تختار قاعدة بيانات علائقية بدل مخزن مستندات (document store)؟
ما الذي يريد المحاور سماعه. معايير محددة، والوعي بأن كثيرًا من الأنظمة تستخدم النوعين معًا.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍI choose a relational database when the data has a clear structure and relationships, and when I need strong consistency and transactions, for example orders and payments. SQL also gives me flexible queries, joins and constraints that protect the data. A document store is a good choice when the data is naturally one nested document, the schema changes often, or I need to scale writes horizontally and I can accept simpler queries. In many projects I use both: a relational database as the source of truth and a document store or a search engine for specific reads.
How does an index work, and what does it cost?
كيف يعمل الفهرس (index) وما كلفته؟
ما الذي يريد المحاور سماعه. البنية والفائدة وكلفة الكتابة وترتيب الأعمدة في الفهرس المركّب.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍAn index is an additional data structure, usually a B-tree, that lets the database find rows without scanning the whole table. It is like the index at the back of a book. It speeds up reads, sorting and joins, but it costs disk space and slows down writes, because every insert and update must also update the index. For a composite index, the order of columns matters, because the database can use only the leftmost part. I create indexes for the real queries, check them with EXPLAIN and remove the ones that are not used.
What does ACID mean?
ماذا يعني ACID؟
ما الذي يريد المحاور سماعه. الخصائص الأربع للمعاملة، مشروحة كلها بمثال واحد.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍACID describes the guarantees of a transaction. Atomicity means that a transaction is all or nothing. Consistency means that it moves the database from one valid state to another, so constraints are respected. Isolation means that concurrent transactions do not see each other's unfinished work, to the degree defined by the isolation level. Durability means that once a transaction is committed, it survives a crash, usually because it is written to a log on disk. A classic example is a money transfer: both the withdrawal and the deposit happen, or neither does.
A query is slow in production. What do you do?
استعلام بطيء في بيئة الإنتاج. ماذا تفعل؟
ما الذي يريد المحاور سماعه. منهجية: القياس، ثم قراءة الخطة، ثم الإصلاح، ثم التحقق.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍFirst I measure, I do not guess. I find the exact query, from the slow query log or monitoring, and run EXPLAIN to see the plan. I look for a full table scan, a missing or unused index, a bad join order or outdated statistics. Often the fix is a better index or a rewritten query. In applications with an ORM, I also check for the N+1 problem, where one request creates hundreds of small queries. After the change, I compare timings with real data volumes, because a query can be fast on a small test database and slow in production.
What are isolation levels, and what problems do they prevent?
ما مستويات العزل (isolation levels) وما المشكلات التي تمنعها؟
ما الذي يريد المحاور سماعه. القراءة القذرة والقراءة غير المتكررة والقراءات الوهمية، والمفاضلة مع التزامن.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍIsolation levels control what a transaction can see from other concurrent transactions. Read committed prevents dirty reads, so you see only committed data. Repeatable read also prevents non-repeatable reads: the same row gives the same value inside one transaction. Serializable also prevents phantom reads, where a repeated query returns new rows, and it behaves as if the transactions ran one by one. Higher levels give more safety but lower concurrency. Many databases, such as PostgreSQL, use read committed by default, and I raise the level only for operations where the anomaly would be a real business problem.
كيف تنطق المصطلحات الأساسية
- SQL
- إِسْ-كِيُو-إِل، أو «سِيكْوِل»
- schema
- سْكِيمَا
- query
- كْوِيرِي
- ACID
- أَسِد
- normalisation
- نُورْمَلَايزِيشِن
- transaction
- تْرَانْزَكْشِن
عبارات مفيدة للإجابة
- The database has to scan the whole table.على قاعدة البيانات أن تمسح الجدول كله.
- It trades read speed for write cost.هذا يكسب سرعة في القراءة مقابل كلفة إضافية في الكتابة.
- I would look at the execution plan first.كنت سأنظر أولًا إلى خطة التنفيذ (execution plan).
- That query uses an index, so it is fast.هذا الاستعلام يستخدم فهرسًا، ولذلك فهو سريع.
- In our system, the source of truth is…في نظامنا، مصدر الحقيقة (source of truth) هو…
- I would measure before I optimise.كنت سأقيس قبل أن أحسّن الأداء.
أخطاء شائعة
- قول «NoSQL أسرع». أسرع في ماذا؟ سمِّ نمط الوصول (access pattern).
- إضافة الفهارس في كل مكان. اذكر كلفة الكتابة، وأنك تفحص الخطة.
- الخلط بين C في ACID (قواعد صحة البيانات) وC في نظرية CAP (الاتساق بين العقد). قل أيهما تقصد.
- عدم ذكر كيف تحققت من الإصلاح. اذكر الخطة (plan) والزمن وحجم البيانات.
الأسئلة الشائعة
كم من SQL سأكتب في المقابلة؟
غالبًا استعلامًا قصيرًا على شاشة مشتركة أو على ورقة: ربطًا (join) أو تجميعًا (group by)، وأحيانًا دالة نافذة (window function). اذكر الخطة قبل أن تكتب: "First I join orders to customers, then I group by month."
أي قاعدة بيانات أقول إنني أعرفها أفضل؟
التي استخدمتها فعلًا. PostgreSQL وMySQL هما الأكثر انتشارًا، وعليك أن تذكر كيف استخدمتهما: تصميم المخطط (schema) والضبط (tuning) وعمليات الترحيل (migrations).
هل أحتاج إلى معرفة البنية الداخلية لقواعد البيانات؟
صورة بسيطة تكفي لمعظم الوظائف: فهارس B-tree وسجل الكتابة المسبقة (write-ahead log) وكيف تعزل المعاملات بعضها عن بعض. المعرفة الأعمق تهم وظائف قواعد البيانات ومنصات البيانات.
قراءة الإجابة ليست مثل قولها. تدرّب على كل سؤال بصوت عالٍ، ثم قارن معنى إجابتك ولغتها بالنموذج.
جرّب SpeakRole ↗موضوعات أخرى في هذا المجال