File manager डिस्क की जगह बाँटता है, फ़ाइलों के ब्लॉक का लेखा रखता है और ऊपरी भागों को ब्लॉक-स्तर की पहुँच देता है। Buffer manager उन ब्लॉकों को स्मृति में लाना-हटाना देखता है, जगह आवंटित नहीं करता। Transaction manager ACID गुण और समवर्तिता सँभालता है, तथा query optimizer योजना चुनता है। दोनों ही डिस्क पर जगह के हिसाब से सीधे नहीं जुड़े, इसलिए यहाँ ठीक नहीं बैठते।
The file manager divides up disk space, keeps an account of the blocks of files, and gives the layers above it block-level access. The buffer manager looks after bringing those blocks into memory and removing them, but allocates no space. The transaction manager handles the ACID properties and concurrency, and the query optimizer picks a plan. Neither deals directly with space on disk, so neither fits here.
प्रश्न 2उत्तर + हल
RDBMS में log फ़ाइल मुख्य रूप से किस काम आती है?
In an RDBMS, what is the log file mainly used for?
AQuery को तेज़ करने वाली अनुक्रमणिका बनाने के लिएTo build indexes that speed up queries
Bउपयोगकर्ताओं के पासवर्ड सुरक्षित रखने के लिएTo keep users' passwords safe
Cविफलता के बाद डेटाबेस को सुसंगत (consistent) स्थिति में लौटाने के लिएTo bring the database back to a consistent state after a failure
Dतालिकाओं का schema और अवरोध रखने के लिएTo hold the schema and constraints of tables
सही उत्तर / Answer: (C)
हल / Solution
Log में हर बदलाव का क्रमवार अभिलेख रहता है, इसलिए क्रैश या बिजली जाने के बाद उसे पढ़कर अधूरे transaction हटाए जा सकते हैं और commit हो चुके transaction दोबारा लगाए जा सकते हैं। Schema तथा अवरोध डेटा डिक्शनरी में रहते हैं, log में नहीं — यही सबसे फँसाने वाला विकल्प है। अनुक्रमणिका अलग ढाँचा है, और पासवर्ड रखना log का काम कभी नहीं रहा।
The log holds an ordered record of every change, so after a crash or a power cut it can be read to remove unfinished transactions and to reapply those that had committed. The schema and constraints live in the data dictionary and not in the log, which is the most tempting wrong option here. An index is a separate structure, and holding passwords has never been the log's job.
प्रश्न 3उत्तर + हल
B+ tree अनुक्रमणिका में root से विभिन्न leaf node तक के रास्तों की लंबाई कैसी होती है?
In a B+ tree index, what can be said about the lengths of the paths from the root to the different leaf nodes?
Aबाईं ओर के रास्ते छोटे और दाईं ओर के लंबे होते हैंPaths towards the left are shorter and those towards the right are longer
Bसभी रास्ते बराबर लंबाई के होते हैंAll the paths are of equal length
Cहर रास्ता भिन्न लंबाई का हो सकता है, कोई नियम नहींEvery path may be of a different length; there is no rule
Dरास्ता केवल एक ही leaf तक होता है, शेष leaf अलग पड़े रहते हैंThere is a path to only one leaf; the remaining leaves stay detached
सही उत्तर / Answer: (B)
हल / Solution
B+ tree संतुलित (balanced) पेड़ है — इसका नियम ही यह है कि प्रत्येक leaf root से समान दूरी पर रहे। जोड़-घटाव के समय node के बँटने और मिलने से पेड़ यही संतुलन बनाए रखता है, इसलिए किसी भी कुंजी की खोज में पढ़े जाने वाले ब्लॉक की संख्या लगभग एक-सी रहती है और प्रदर्शन अनुमान योग्य बनता है। असंतुलन या कटे हुए leaf वाले शेष तीनों विकल्प इस परिभाषा के ही विरुद्ध हैं।
A B+ tree is a balanced tree; its very rule is that every leaf stays at the same distance from the root. Splitting and merging nodes during insertion and deletion keeps that balance, so the number of blocks read while searching for any key stays nearly the same and performance becomes predictable. The other three options describe an unbalanced tree or detached leaves and go against this definition.
प्रश्न 4उत्तर + हल
अनुक्रमणिका (index) स्वयं इतनी बड़ी हो जाए कि एक ब्लॉक में न समाए, तो उसका मानक हल क्या है?
If an index itself grows so large that it does not fit in one block, what is the standard solution?
Aबहु-स्तरीय (multilevel) अनुक्रमणिका बनाना, अर्थात् अनुक्रमणिका पर ही एक और अनुक्रमणिकाBuild a multilevel index, that is, an index on the index itself
Bअनुक्रमणिका हटा देना, क्योंकि वह अब बेकार हो गईDrop the index, because it has now become useless
Cअनुक्रमणिका को buffer में स्थायी रूप से pin कर देनाPin the index permanently in the buffer
Dतालिका को दो हिस्सों में बाँट देना अनिवार्य हो जाता हैIt becomes compulsory to split the table into two parts
सही उत्तर / Answer: (A)
हल / Solution
एक ब्लॉक से बड़ी अनुक्रमणिका को क्रमिक रूप से टटोलना पड़े तो उसका लाभ ही जाता रहता है। इसलिए भीतरी अनुक्रमणिका पर एक विरल (sparse) बाहरी अनुक्रमणिका बनाई जाती है, और यही क्रम दोहराकर B+ tree जैसा बहु-स्तरीय ढाँचा बनता है, जिसमें कुछ ही पहुँच में कुंजी मिल जाती है। अनुक्रमणिका हटाना समस्या से भागना है, पूरी अनुक्रमणिका स्मृति में pin रखना संभव नहीं, और तालिका बाँटना यहाँ आवश्यक नहीं।
If an index larger than a block has to be scanned sequentially, its whole benefit is lost. So a sparse outer index is built over the inner index, and repeating this gives a multilevel structure such as a B+ tree, in which a key is found in only a few accesses. Dropping the index is running away from the problem, pinning a whole index in memory is not feasible, and splitting the table is not needed here.
प्रश्न 5उत्तर + हल
Parsing के बाद SQL query को DBMS किस भीतरी रूप में बदलता है, जिस पर optimizer आगे काम करता है?
After parsing, into what internal form does a DBMS convert an SQL query, on which the optimizer then works?
Aएक और SQL कथन में, जो उपयोगकर्ता को दिखाया जाता हैInto another SQL statement, which is then shown to the user
Bसीधे मशीन भाषा के अंतिम निर्देशों मेंDirectly into final machine language instructions
CRelational algebra की अभिव्यक्ति, जिसे query tree भी कहते हैंAn expression of relational algebra, also called a query tree
DLog फ़ाइल के एक अभिलेख मेंInto a record of the log file
सही उत्तर / Answer: (C)
हल / Solution
SQL कहता है «क्या चाहिए», पर optimizer को «कैसे लाएँ» पर काम करना है। इसलिए parser query को relational algebra की अभिव्यक्ति में बदलता है, जहाँ चयन, प्रक्षेप और join अलग-अलग संक्रियाओं के रूप में दिखते हैं और उनका क्रम बदलकर सस्ती योजना खोजी जा सकती है। मशीन भाषा बहुत बाद का चरण है, log recovery के लिए है, और भीतरी रूप उपयोगकर्ता को दिखाने की वस्तु नहीं है।
SQL says what is wanted, but the optimizer has to work on how to fetch it. So the parser converts the query into an expression of relational algebra, where selection, projection and join appear as separate operations whose order can be rearranged to find a cheaper plan. Machine language comes at a much later stage, the log exists for recovery, and an internal form is not something shown to the user.
प्रश्न 6उत्तर + हल
किसी बड़ी तालिका का पूरा क्रमिक (sequential) स्कैन करते समय LRU नीति अच्छी नहीं मानी जाती। इसका कारण क्या है?
The LRU policy is not considered good while a large table is being scanned sequentially from end to end. What is the reason?
Aस्कैन में जो पन्ना अभी पढ़ा गया है उसकी दोबारा ज़रूरत सबसे बाद में पड़ती है, पर LRU उसी को सबसे देर तक रोके रखती हैThe page just read in a scan will be needed again last of all, yet LRU is the policy that holds on to it longest
BLRU को प्रत्येक पन्ने के लिए डिस्क पर अलग अभिलेख रखना पड़ता हैLRU has to keep a separate record on disk for every page
CLRU केवल एक उपयोगकर्ता वाले सिस्टम पर चल सकती हैLRU can work only on a single-user system
DLRU गंदे (dirty) पन्ने को डिस्क पर लिखना ही भूल जाती हैLRU simply forgets to write dirty pages out to disk
सही उत्तर / Answer: (A)
हल / Solution
LRU यह मानकर चलती है कि हाल में पढ़ा पन्ना फिर जल्दी चाहिए होगा। पूरे स्कैन में यह मान्यता उलट जाती है: पन्ना एक बार पढ़कर छोड़ दिया जाता है और अगली बार उसकी बारी पूरे चक्कर के बाद आती है। इसीलिए यहाँ MRU या toss-immediate जैसी नीति अधिक ठीक बैठती है। LRU का हिसाब स्मृति में रहता है, वह बहु-उपयोगकर्ता सिस्टम में भी चलती है, और गंदे पन्ने लिखे ही जाते हैं।
LRU assumes that a page read recently will soon be wanted again. A full scan turns that assumption upside down: a page is read once and dropped, and its turn comes again only after the whole sweep. This is why a policy such as MRU or toss-immediate suits the case better. LRU keeps its bookkeeping in memory, it works on multi-user systems too, and dirty pages are certainly written out.
प्रश्न 7उत्तर + हल
क्रैश (crash) के बाद पुनर्प्राप्ति में log पढ़कर किन transaction को redo और किन्हें undo किया जाता है?
During recovery after a crash, while reading the log, which transactions are redone and which are undone?
Aजिनका commit अभिलेख मिल जाए उन्हें undo, और शेष को redoThose whose commit record is found are undone, and the rest are redone
Bजिनका commit अभिलेख log में मिल जाए उन्हें redo, और जिनका commit अभिलेख न मिले उन्हें undoThose whose commit record is found in the log are redone, and those whose commit record is missing are undone
Cसभी transaction को redo; undo की आवश्यकता कभी नहीं पड़तीEvery transaction is redone; undo is never needed
Dकेवल अंतिम transaction को undo, शेष को छोड़ दिया जाता हैOnly the last transaction is undone and the rest are left alone
सही उत्तर / Answer: (B)
हल / Solution
Commit अभिलेख इस बात का प्रमाण है कि transaction पूरा हुआ और उसका असर टिकना चाहिए; उसके पन्ने buffer में रह गए हो सकते हैं, इसलिए log से उन्हें दोबारा लगाया जाता है। Commit अभिलेख न होने का अर्थ है transaction बीच में टूटा, सो उसका आधा असर मिटाना पड़ता है, वरना परमाण्विकता (atomicity) टूटेगी। «commit मिले तो undo» वाला विकल्प ठीक उल्टा है, और शेष दोनों दोनों में से एक काम छोड़ देते हैं।
A commit record is proof that a transaction finished and that its effect must last; its pages may still be sitting in the buffer, so they are reapplied from the log. A missing commit record means the transaction broke midway, so its half-made effect has to be wiped out, or atomicity would fail. The choice that undoes the committed ones is exactly the reverse, and the other two drop one of the two jobs altogether.
प्रश्न 8उत्तर + हल
MySQL के InnoDB storage engine में प्रत्येक तालिका का डेटा किस रूप में रखा जाता है?
In the InnoDB storage engine of MySQL, in what form is the data of each table kept?
Aप्राथमिक कुंजी (Primary Key) के B+ tree की leaf में ही पूरी पंक्ति — अर्थात् तालिका स्वयं एक clustered index हैThe whole row sits in the leaf of the primary key's B+ tree, that is, the table itself is a clustered index
Bएक heap फ़ाइल में, और प्राथमिक कुंजी की अनुक्रमणिका उससे पूरी तरह अलगIn a heap file, with the primary key index kept entirely separate from it
Cकेवल एक hash तालिका के रूप मेंOnly as a hash table
Dप्रत्येक स्तंभ अलग फ़ाइल में, स्तंभ-वार (column-wise)Each column in a separate file, column-wise
सही उत्तर / Answer: (A)
हल / Solution
InnoDB तालिका को प्राथमिक कुंजी के क्रम में सजाकर रखता है और पंक्ति का पूरा विवरण उसी B+ tree की leaf में रखता है, इसलिए प्राथमिक कुंजी से खोज एक ही पहुँच में पंक्ति दे देती है। इसी कारण उसकी गौण (secondary) अनुक्रमणिका में पंक्ति का पता नहीं, प्राथमिक कुंजी का मान रहता है। Heap वाला ढाँचा कुछ अन्य इंजन अपनाते हैं, और स्तंभ-वार संचय विश्लेषणात्मक डेटाबेस का तरीक़ा है।
InnoDB keeps a table arranged in primary key order and stores the full row in the leaf of that B+ tree, so a lookup by primary key returns the row in a single access. For the same reason its secondary indexes store the primary key value rather than a row address. The heap arrangement is what some other engines choose, and column-wise storage is the way of analytical databases.
प्रश्न 9उत्तर + हल
निम्न में से कौन RDBMS के query processor का हिस्सा है?
Which of the following is a part of the query processor of an RDBMS?
Query processor में DDL को समझने वाला भाग, DML को निम्न-स्तरीय क्रियाओं में बदलने वाला भाग, query optimizer तथा query निष्पादन इंजन आते हैं — यानी query को समझने, सुधारने और चलाने का सारा काम। Buffer manager और file manager storage manager के उप-घटक हैं, जो स्मृति और डिस्क सँभालते हैं। Lock manager transaction manager के साथ रहता है और समवर्तिता देखता है, query की योजना नहीं बनाता।
The query processor holds the part that interprets DDL, the part that turns DML into low-level operations, the query optimizer and the query evaluation engine, that is, all the work of understanding, improving and running a query. The buffer manager and file manager are sub-components of the storage manager and look after memory and disk. The lock manager sits with the transaction manager and handles concurrency, not query planning.
प्रश्न 10उत्तर + हल
WAL की log फ़ाइल में किसी update के अभिलेख (log record) में सामान्यतः क्या-क्या रहता है?
In write-ahead logging, what does a log record for an update normally contain?
Aपूरी तालिका की एक प्रतिA copy of the entire table
Bकेवल नया मान, क्योंकि पुराने मान की कभी ज़रूरत नहीं पड़तीOnly the new value, since the old value is never needed
Cकेवल transaction की पहचान और समयOnly the transaction identifier and the time
DTransaction की पहचान, बदले गए डेटा आइटम का नाम, उसका पुराना मान और नया मानThe transaction identifier, the name of the data item changed, its old value and its new value
सही उत्तर / Answer: (D)
हल / Solution
Recovery में दो उलटे काम करने पड़ते हैं — अधूरे transaction का असर मिटाना और commit हो चुके transaction का असर दोबारा लगाना। मिटाने के लिए पुराना मान चाहिए, दोबारा लगाने के लिए नया; इसलिए अभिलेख में दोनों रखे जाते हैं, साथ में transaction की पहचान और आइटम का नाम। केवल नया मान रखने पर undo असंभव हो जाता, और पूरी तालिका की प्रति log को डेटाबेस से भी बड़ा कर देती।
Recovery has to do two opposite things: wipe out the effect of an unfinished transaction and reapply the effect of one that committed. Wiping out needs the old value and reapplying needs the new one, so the record carries both, along with the transaction identifier and the name of the item. Keeping only the new value would make undo impossible, and copying a whole table would make the log larger than the database.
आगे के 15 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
Cost-based optimizer किसी योजना की लागत आँकने के लिए तालिकाओं की पंक्ति-संख्या और मानों के वितरण जैसे आँकड़े कहाँ से लेता है?
Where does a cost-based optimizer obtain statistics such as row counts and value distributions, which it needs in order to estimate the cost of a plan?
Alog फ़ाइल सेFrom the log file
Bहर query के समय पूरी तालिका गिनकर, उसी क्षणBy counting the whole table at the moment each query arrives
Cकेवल उपयोगकर्ता की query में दिए गए संकेतों से, और कहीं से नहींOnly from hints given inside the user's query, and from nowhere else
Dडेटा डिक्शनरी अर्थात् system catalog सेFrom the data dictionary, that is, the system catalog
डेटाबेस का buffer manager, operating system के virtual memory प्रबंध पर छोड़ने के बजाय अपना अलग buffer क्यों रखता है?
Why does a database buffer manager keep its own buffer instead of leaving the job to the operating system's virtual memory management?
Aक्योंकि DBMS जानता है कि आगे कौन-सा पन्ना चाहिए और किस पन्ने को डिस्क पर कब लिखना है — recovery के नियम इसी नियंत्रण से निभते हैंBecause the DBMS knows which page will be needed next and when a page must be written to disk, and the recovery rules depend on exactly this control
Bक्योंकि operating system में मुख्य स्मृति का प्रबंध ही नहीं होताBecause an operating system does not manage main memory at all
Cक्योंकि DBMS का buffer स्मृति में नहीं, डिस्क पर रखा जाता हैBecause the buffer of a DBMS is kept on disk and not in memory
Dक्योंकि virtual memory केवल एक उपयोगकर्ता वाले सिस्टम में काम करती हैBecause virtual memory works only on a single-user system
Non-clustered index से किसी पंक्ति का पूरा विवरण पाने में clustered index की तुलना में एक अतिरिक्त चरण क्यों लगता है?
Why does fetching a full row through a non-clustered index take one extra step compared with a clustered index?
ANon-clustered index की leaf में पंक्ति का पता (row locator) रहता है, पंक्ति स्वयं नहीं — इसलिए उस पते से पंक्ति अलग से लानी पड़ती हैThe leaf of a non-clustered index holds a row locator rather than the row itself, so the row has to be fetched separately using that locator
BNon-clustered index हर खोज से पहले नए सिरे से बनाया जाता हैA non-clustered index is rebuilt from scratch before every search
CNon-clustered index डिस्क पर नहीं, केवल buffer में रहता हैA non-clustered index lives only in the buffer and not on disk
DNon-clustered index में कुंजी के मान क्रम में नहीं रखे जाते, इसलिए पूरी तालिका टटोलनी पड़ती हैA non-clustered index does not keep key values in order, so the whole table must be scanned
किसी तालिका पर वेतन के परिसर (range) वाली query, जैसे 20000 से 30000 के बीच के वेतन छाँटना — इसके लिए वेतन स्तंभ पर निम्न में से कौन-सा संगठन सबसे कम उपयोगी है?
For a range query on a table, such as selecting salaries between 20000 and 30000, which of the following organizations on the salary column is the least useful?
Aवेतन पर clustered indexA clustered index on salary
Bवेतन पर क्रमित (sorted) संगठनA sorted organization on salary
Cवेतन पर B+ tree अनुक्रमणिकाA B+ tree index on salary
RDBMS का transaction manager मुख्य रूप से किस बात का ध्यान रखता है?
What does the transaction manager of an RDBMS primarily take care of?
ASQL query को भीतरी बीजीय (algebraic) रूप में बदलनाConverting an SQL query into an internal algebraic form
Bडिस्क पर फ़ाइलों के लिए जगह आवंटित करना और मुक्त करनाAllocating and freeing space for files on disk
Cविफलता तथा समवर्ती (concurrent) पहुँच के बावजूद डेटाबेस सुसंगत (consistent) बना रहेThat the database stays consistent in spite of failures and concurrent access
Dउपयोगकर्ताओं के लिए रिपोर्ट और फ़ॉर्म बनानाBuilding reports and forms for users
RDBMS में CREATE TABLE कथन चलाने पर तुरंत क्या होता है?
What happens immediately inside an RDBMS when a CREATE TABLE statement is executed?
Aतालिका की सभी पंक्तियाँ buffer में भर दी जाती हैंAll the rows of the table are loaded into the buffer
Bनई तालिका का विवरण — नाम, स्तंभ, डेटा प्रकार और अवरोध — डेटा डिक्शनरी में दर्ज हो जाता हैThe description of the new table — its name, columns, data types and constraints — is recorded in the data dictionary
Cतालिका पर स्वतः एक clustered तथा एक hash index, दोनों बन जाते हैंBoth a clustered index and a hash index are built on the table automatically
Dडेटा डिक्शनरी की पुरानी प्रविष्टियाँ मिटा दी जाती हैंThe older entries of the data dictionary are erased
Rule-based (नियम-आधारित) query optimizer की मुख्य सीमा क्या है?
What is the main limitation of a rule-based query optimizer?
Aयह अनुक्रमणिका (index) का उपयोग कभी नहीं कर सकताIt can never make use of an index
Bयह हर query की सभी संभव योजनाओं की लागत गिनता है, इसलिए बहुत समय लेता हैIt computes the cost of every possible plan for a query, so it takes a great deal of time
Cयह तालिकाओं के आकार और मानों के वितरण को नहीं देखता, पहुँच-मार्गों की एक निश्चित प्राथमिकता सूची से चलता हैIt ignores table sizes and the distribution of values, and goes by a fixed priority list of access paths
Dयह केवल एक तालिका वाली query चला सकता है, join वाली नहींIt can run only single-table queries, not queries with joins
Write-Ahead Logging (WAL) का पालन करने वाले सिस्टम में किसी transaction के commit को टिकाऊ (durable) मानने के लिए क्या अनिवार्य है?
In a system following Write-Ahead Logging (WAL), what must happen before a transaction's commit can be treated as durable?
Aउस transaction के सभी lock छोड़ दिए गए होंAll locks of that transaction have been released
Bउस transaction से बदले गए सभी डेटा पन्ने स्थायी भंडार पर लिख दिए गए होंAll data pages changed by that transaction have been written to stable storage
Cपूरे डेटाबेस की एक नई प्रति बना ली गई होA fresh copy of the whole database has been taken
Dउस transaction के सभी log अभिलेख, commit अभिलेख सहित, स्थायी भंडार पर लिख दिए गए होंAll log records of that transaction, including its commit record, have been written to stable storage
किसी एक तालिका पर clustered index केवल एक ही बनाया जा सकता है। इसका कारण क्या है?
Only one clustered index can be created on a single table. What is the reason for this?
AClustered index केवल प्राथमिक कुंजी (Primary Key) पर ही बन सकता है, और प्राथमिक कुंजी एक ही होती हैA clustered index can be built only on the primary key, and there is only one primary key
BClustered index पंक्तियों का भौतिक (physical) क्रम ही तय करता है, और पंक्तियाँ डिस्क पर एक समय में एक ही क्रम में रखी जा सकती हैंA clustered index decides the physical order of the rows, and rows can be kept on disk in only one order at a time
CClustered index के लिए अलग से जगह नहीं लगती, इसलिए दूसरा बनाने से कोई लाभ नहीं मिलताA clustered index needs no extra space, so building a second one brings no benefit
DSQL मानक किसी तालिका पर कुल मिलाकर केवल एक ही index की अनुमति देता हैThe SQL standard allows only one index in total on a table
B tree और B+ tree अनुक्रमणिका (index) में मुख्य अंतर क्या है?
What is the main difference between a B tree and a B+ tree index?
AB+ tree असंतुलित (unbalanced) होता है, जबकि B tree सदैव संतुलित रहता हैA B+ tree is unbalanced, whereas a B tree is always balanced
BB+ tree के प्रत्येक node में अधिकतम दो ही संतान (child) हो सकती हैं, जबकि B tree में दो से अधिकA node of a B+ tree can have at most two children, whereas a B tree node can have more than two
CB+ tree में अभिलेखों की ओर इशारा करने वाले सूचक (pointer) केवल leaf node में रहते हैं, और सभी leaf node क्रम से एक शृंखला (linked list) में जुड़े रहते हैंIn a B+ tree the pointers to records sit only in the leaf nodes, and all the leaf nodes are chained together in order as a linked list
DB+ tree में खोज root node पर ही पूरी हो जाती है, leaf तक जाने की ज़रूरत नहीं पड़तीIn a B+ tree the search finishes at the root node itself and never has to reach a leaf
RDBMS के भीतरी ढाँचे में डिस्क पर डेटा का संचय, उसकी पुनःप्राप्ति तथा डिस्क और मुख्य स्मृति के बीच पन्नों (pages) की आवाजाही किस घटक की ज़िम्मेदारी है?
In the internal architecture of an RDBMS, which component is responsible for storing data on disk, retrieving it, and moving pages between disk and main memory?