2026 में डेटाबेस साक्षात्कार प्रश्न SQL बुनियादी बातों, लेनदेन, अनुक्रमण, सामान्यीकरण, NoSQL बनाम 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. ACID गुण क्या हैं?
- परमाणुता: लेन-देन सब कुछ है या कुछ भी नहीं – $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. आप SQL के स्थान पर NoSQL कब चुनेंगे?
| SQL कब चुनें | जब NoSQL चुनें |
|---|---|
| जटिल रिश्ते (जॉइन्स) | सरल पहुंच पैटर्न (कुंजी-मूल्य) |
| ACID लेनदेन की आवश्यकता है | बड़े पैमाने पर (शार्डिंग आवश्यक) |
| जटिल प्रश्न, एकत्रीकरण | लचीली स्कीमा |
| वित्तीय, इन्वेंट्री डेटा | उच्च लेखन थ्रूपुट |
| टीम एसक्यूएल जानती है | 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)
डेटाबेस साक्षात्कार परीक्षण चौड़ाई (एसक्यूएल, सामान्यीकरण, एसीआईडी) और गहराई (क्वेरी अनुकूलन, अनुक्रमण रणनीति)। जानें कि EXPLAIN ANALYZE का उपयोग कैसे करें, समझें कि प्रत्येक सूचकांक प्रकार कब मदद करता है, और शेयरिंग ट्रेड-ऑफ़ को स्पष्ट रूप से समझाएं। उत्पादन प्रश्न अक्सर कनेक्शन पूलिंग, प्रतिकृति अंतराल और एन+1 प्रश्नों को संभालने से संबंधित होते हैं।
🔗 Share this article
✍️ Leave a Comment