Database Management Systems (DBMS)
Schools, libraries and offices need organised records of students, books, employees and examination applications. A database organises this data. A DBMS is the software used to create, search and manage databases.
Scope: This chapter covers DBMS at the Computer Awareness level of general recruitment examinations. SQL examples illustrate concepts. Data types, command classifications and some behaviours can differ between database products.
1. Data, Information, Database and DBMS
| Term | Meaning | Example |
| Data | Raw facts or values. | Marks of 45, 60 and 75. |
| Information | Organised or processed data with context. | The average mark of these three students is 60. |
| Database | An organised collection of related data. | Library book and member records. |
| DBMS | Database Management System; software that manages databases. | Microsoft Access, MySQL and Microsoft SQL Server. |
Important distinction: A database is the collection of data; a DBMS is the software that manages it. They are not the same thing.
2. Main Functions of a DBMS
- Creating database and table structures.
- Adding, changing and deleting records.
- Retrieving information that satisfies specified conditions.
- Enforcing data rules and relationships.
- Providing appropriate access to authorised users.
- Managing work by concurrent users.
- Providing backup and recovery facilities.
Benefit: Suitable database design reduces unnecessary duplication and helps maintain consistent data.
Remember: Using a DBMS does not automatically eliminate every error or all duplication. Correct design, constraints, permissions and backups are also necessary.
3. Tables, Fields and Records
Relational databases organise data into tables. Consider this example Employees table:
| EmployeeID | EmployeeName | DepartmentID |
| 101 | Asha | 10 |
| 102 | Ravi | 20 |
| 103 | Neha | 10 |
- Table: A collection of related records.
- Field/Column: A particular characteristic, such as EmployeeName.
- Record/Row: Details about one entity, such as the complete record for employee 101.
- Attribute: The relational term for a column characteristic.
- Tuple: The relational term for a row.
This example contains 3 records and 3 fields. The header row is not a data record.
Degree: The number of attributes in a relation. Cardinality: The number of tuples in a relation. Both are 3 in this example.
4. DBMS, RDBMS and Data Models
RDBMS stands for Relational Database Management System. It is a DBMS based on the relational model, where tables and relationships are important.
Relationship: Every RDBMS is a DBMS, but not every DBMS must be relational.
| Data model | Main characteristic |
| Hierarchical | A tree-like parent–child structure. |
| Network | A structure supporting multiple links between records. |
| Relational | Data in tables, with keys supporting relationships. |
MySQL, PostgreSQL, Oracle Database and Microsoft SQL Server are examples of relational database systems.
5. Primary Key and Other Important Keys
A key can consist of one or more columns used to identify records or establish relationships.
| Key | Meaning |
| Super Key | A column or set of columns that uniquely identifies a record. |
| Candidate Key | A minimal super key with no unnecessary column. |
| Primary Key | The candidate key selected as the main record identifier. |
| Alternate Key | A candidate key not selected as the primary key. |
| Composite Key | A key formed from more than one column. |
Primary key rules: Its values must be unique and cannot be NULL. A table has one primary key, but that key can contain multiple columns.
Example: EmployeeID can identify an employee. A name alone may be unsuitable because different employees can share the same name.
Composite example: If a student can enrol in each course only once, the combination of StudentID and CourseID can identify an Enrolments record.
6. Foreign Keys and Referential Integrity
A foreign key is a column or set of columns referencing a primary key or suitable unique key. A reference can also point to the same table.
Example: DepartmentID identifies departments in a Departments table. DepartmentID in Employees can reference the department where an employee works.
- Foreign key values can repeat because several employees can belong to the same department.
- A foreign key can allow NULL unless another rule, such as NOT NULL, prevents it.
- Referential integrity: Maintaining valid relationships, such as requiring a recorded employee department to exist in the referenced department list.
Exam distinction: A primary key supplies the main identity. A foreign key enforces the validity of a relationship. A foreign key is not necessarily unique.
7. Relationships Between Tables
| Relationship | Example |
| One-to-One | One employee and that employee's single detailed profile. |
| One-to-Many | One department has several employees, with each employee assigned to one department. |
| Many-to-Many | A student takes several courses, and each course has several students. |
A many-to-many relationship is commonly represented through a junction table, such as Enrolments between Students and Courses.
8. Data Types and NULL
- Integer: Whole numbers, such as the number of books.
- Decimal: Values with specified decimal precision, such as amounts.
- Text/Character: Names, addresses or identification codes.
- Date/Time: Dates and times.
- Boolean/Yes-No: True–false states; naming and storage depend on the product.
NULL generally represents an unknown or unavailable value. It is not the same as zero or empty text.
Example: A Marks value of 0 can mean zero marks. NULL can mean that the marks are not yet available.
Practical understanding: A telephone number or identifier with leading zeros may appropriately use a text type even though it contains digits, because it is not intended for arithmetic.
9. SQL and Important Commands
SQL stands for Structured Query Language. It is used to retrieve and change data and work with structures in relational databases. SQL itself is not the name of a DBMS.
| Group | Full form | Common examples |
| DDL | Data Definition Language | CREATE, ALTER, DROP |
| DML | Data Manipulation Language | INSERT, UPDATE, DELETE |
| DQL | Data Query Language | SELECT |
| DCL | Data Control Language | GRANT, REVOKE |
| TCL | Transaction Control Language | COMMIT, ROLLBACK |
Classification note: This grouping is common in competitive-exam textbooks. Products do not all classify statements identically. Some official documentation includes SELECT under DML. Understand what each command actually does.
10. SELECT, WHERE and ORDER BY
Assume a Candidates table contains CandidateID, CandidateName and Marks.
SELECT CandidateName, Marks
FROM Candidates
WHERE Marks >= 60
ORDER BY Marks DESC, CandidateID ASC;
- SELECT: Specifies the columns to display.
- FROM: Identifies the source table.
- WHERE: Selects records satisfying a condition.
- ORDER BY: Specifies the result order.
- DESC: Descending order; higher marks first.
- ASC: Ascending order; smaller CandidateID first among equal marks.
Important fact: Without ORDER BY, a fixed result order should not be assumed. Having a primary key does not itself guarantee SELECT output order.
Testing NULL: Use WHERE Marks IS NULL to find unavailable marks. Marks = NULL is not the correct ordinary test.
11. Aggregate Functions and JOIN
| Function | Purpose |
| COUNT(*) | Counts all rows in the result. |
| COUNT(Marks) | Counts rows with non-NULL Marks. |
| SUM(Marks) | Adds the marks. |
| AVG(Marks) | Averages non-NULL marks. |
| MAX(Marks) | Returns the largest value. |
| MIN(Marks) | Returns the smallest value. |
Example: For Marks values of 50, NULL and 70, COUNT(*) = 3, COUNT(Marks) = 2 and AVG(Marks) = 60.
GROUP BY groups records with common values, such as counting employees by department. HAVING applies conditions to groups.
A JOIN combines related data in a query result:
- INNER JOIN: Returns matching records from both sides according to the join condition.
- LEFT JOIN: Retains all left-side records and matching right-side records; unmatched right-side values appear as NULL.
A JOIN does not permanently turn the original tables into one table.
12. DELETE, TRUNCATE and DROP
| Command | Main purpose |
| DELETE | Removes rows; WHERE can select particular records. |
| TRUNCATE TABLE | Empties the table without an ordinary WHERE condition; the table structure remains. |
| DROP TABLE | Removes the table object and its stored data. |
Caution: DELETE or UPDATE without WHERE can affect all rows. It is also incorrect to claim that TRUNCATE can never be rolled back in any DBMS; transaction behaviour depends on the product.
13. Redundancy, Normalization, Indexes and Views
- Data redundancy: Unnecessary repetition of the same fact.
- Data inconsistency: Conflicting values for the same fact in different records.
- Normalization: Organising tables and relationships to reduce unnecessary repetition and update-related problems.
- Index: An auxiliary structure that can speed up suitable searches, with additional storage and maintenance costs.
- View: A named representation based on a query; an ordinary view does not store a separate permanent copy of its result.
Example: Keeping department names in Departments and referencing DepartmentID from Employees can reduce repeated department information in employee records.
Remember: An index does not mean records will be displayed in ascending order. Use ORDER BY to specify the result order.
14. Transactions, ACID and DBA
A transaction is a logical unit of related database operations. For example, issuing a library book may require both adding an issue record and reducing the available-copy count.
| Property | Simple meaning |
| Atomicity | All the work takes effect, or none of it does. |
| Consistency | The transaction preserves defined database rules. |
| Isolation | Concurrent transactions interact according to the selected isolation rules. |
| Durability | Successfully committed changes remain persistent. |
COMMIT accepts a transaction's changes. ROLLBACK reverses uncommitted changes within its applicable scope.
DBA: Database Administrator. Responsibilities include permissions, security, backups, recovery and performance monitoring.
A backup is a recoverable copy of data. Recovery restores the database to an appropriate state after a problem. Creating backups alone is insufficient; testing restoration is also important.
15. Microsoft Access and Quick Revision
Microsoft Access is a desktop database application. A typical modern Access database uses .accdb; the older format uses .mdb.
| Object | Purpose |
| Table | Stores data. |
| Query | Retrieves required data or performs actions, depending on its type. |
| Form | Provides a convenient interface for viewing, entering and editing data. |
| Report | Produces organised, presentation-ready or printable output. |
- Row = Record; Column = Field.
- A primary key is unique and non-NULL.
- Foreign key values can repeat.
- WHERE selects records; ORDER BY sorts the result.
- COUNT(*) counts all rows; COUNT(Column) excludes NULL.
- DELETE removes rows; DROP TABLE removes the table object.
- Forms help with data entry; reports provide organised output.
16. Practice Questions
These are original practice questions, not verified previous-year questions. Each question has one correct answer.
Question 1. What is a database row containing the complete details of one employee called?
A. Field
B. Record
C. Data Type
D. Index
View answer and explanation
Correct answer: B. Record
A record contains details about one entity. A field represents a particular characteristic.
Question 2. A relation has 6 attributes and 25 tuples. What is its degree?
A. 25
B. 150
C. 6
D. 31
View answer and explanation
Correct answer: C. 6
Degree is the number of attributes. Cardinality is the number of tuples.
Question 3. Which statement about a primary key is correct?
A. It uniquely identifies records and does not allow NULL.
B. Duplicate values are compulsory.
C. It always consists of exactly one column.
D. It can be created only on text data.
View answer and explanation
Correct answer: A. It uniquely identifies records and does not allow NULL.
A primary key can consist of one column or a combination of columns.
Question 4. DepartmentID in Employees references a valid department identifier in Departments. Which key does this illustrate?
A. Alternate Key
B. Candidate Key
C. Super Key
D. Foreign Key
View answer and explanation
Correct answer: D. Foreign Key
A foreign key enforces a valid relationship with referenced records.
Question 5. One department has several employees, and each employee belongs to one department. What is the department-to-employee relationship?
A. One-to-One
B. One-to-Many
C. Many-to-Many
D. No relationship
View answer and explanation
Correct answer: B. One-to-Many
One department record is associated with multiple employee records.
Question 6. Which clause displays SELECT results in descending order of marks?
A. ORDER BY Marks DESC
B. WHERE Marks ASC
C. GROUP BY Marks DESC
D. SELECT DESC Marks
View answer and explanation
Correct answer: A. ORDER BY Marks DESC
ORDER BY specifies the result order, and DESC means descending.
Question 7. Marks contains 50, NULL and 70. What does COUNT(Marks) return?
A. 3
B. 120
C. 2
D. 60
View answer and explanation
Correct answer: C. 2
COUNT(Marks) counts non-NULL values. There are two: 50 and 70.
Question 8. Which condition correctly finds records whose Marks value is unavailable?
A. WHERE Marks = 0
B. WHERE Marks = NULL
C. WHERE Marks = 'NULL'
D. WHERE Marks IS NULL
View answer and explanation
Correct answer: D. WHERE Marks IS NULL
IS NULL tests for NULL. NULL is neither zero nor the text 'NULL'.
Question 9. Which command removes records satisfying a WHERE condition without removing the table structure?
A. DROP TABLE
B. DELETE
C. CREATE TABLE
D. GRANT
View answer and explanation
Correct answer: B. DELETE
DELETE can use WHERE to remove selected rows.
Question 10. Which process helps reduce unnecessary data repetition and related update problems?
A. Normalization
B. Slide Transition
C. Mail Merge
D. Defragmentation
View answer and explanation
Correct answer: A. Normalization
Normalization organises tables and relationships to reduce unnecessary duplication.
Question 11. Which transaction property represents the “all or nothing” principle?
A. Durability
B. Indexing
C. Atomicity
D. Sorting
View answer and explanation
Correct answer: C. Atomicity
Atomicity means the related changes take effect as a complete unit or do not take effect.
Question 12. Which MS Access object is suitable for presenting a monthly employee list in an organised printable format?
A. Field
B. Primary Key
C. Relationship
D. Report
View answer and explanation
Correct answer: D. Report
A report provides organised output suitable for presentation and printing.
डेटाबेस मैनेजमेंट सिस्टम (DBMS)
विद्यालय के विद्यार्थियों, पुस्तकालय की पुस्तकों, कर्मचारियों और परीक्षा आवेदनों का विवरण व्यवस्थित रूप से रखना आवश्यक होता है। डेटाबेस इस डेटा को संगठित करने में सहायता करता है। DBMS वह सॉफ्टवेयर है जिससे डेटाबेस बनाया, खोजा और प्रबंधित किया जाता है।
अध्याय का दायरा: यह अध्याय सामान्य नौकरी-संबंधी प्रतियोगी परीक्षाओं के Computer Awareness स्तर पर आधारित है। SQL उदाहरण अवधारणा समझाने के लिए हैं। विभिन्न डेटाबेस उत्पादों में डेटा टाइप, कमांड वर्गीकरण और कुछ व्यवहार अलग हो सकते हैं।
1. Data, Information, Database और DBMS
| शब्द | अर्थ | उदाहरण |
| Data | कच्चे तथ्य या मान। | 45, 60, 75 अंक। |
| Information | संदर्भ सहित व्यवस्थित या संसाधित डेटा। | इन तीन विद्यार्थियों के औसत अंक 60 हैं। |
| Database | संबंधित डेटा का संगठित संग्रह। | पुस्तकालय की पुस्तकें और सदस्य रिकॉर्ड। |
| DBMS | Database Management System; डेटाबेस प्रबंधित करने वाला सॉफ्टवेयर। | Microsoft Access, MySQL, Microsoft SQL Server। |
महत्वपूर्ण अंतर: Database डेटा का संग्रह है; DBMS उस संग्रह को संभालने वाला सॉफ्टवेयर है। दोनों एक ही चीज नहीं हैं।
2. DBMS के प्रमुख कार्य
- डेटाबेस और टेबल की संरचना बनाना।
- नए रिकॉर्ड जोड़ना और पुराने रिकॉर्ड बदलना या हटाना।
- शर्त के अनुसार आवश्यक जानकारी प्राप्त करना।
- डेटा के लिए नियम और संबंध लागू करना।
- अधिकृत उपयोगकर्ताओं को उचित पहुँच देना।
- एक साथ अनेक उपयोगकर्ताओं के कार्य का प्रबंधन करना।
- बैकअप और रिकवरी की व्यवस्था उपलब्ध कराना।
लाभ: उचित डेटाबेस डिजाइन अनावश्यक दोहराव कम करता है और डेटा की संगति बनाए रखने में सहायता करता है।
ध्यान दें: DBMS का उपयोग करने मात्र से हर गलती या हर प्रकार का डेटा दोहराव स्वतः समाप्त नहीं होता। सही डिजाइन, नियम, अनुमतियाँ और बैकअप भी आवश्यक हैं।
3. Table, Field और Record
रिलेशनल डेटाबेस में डेटा टेबलों के रूप में व्यवस्थित होता है। नीचे Employees नाम की एक उदाहरण टेबल है:
| EmployeeID | EmployeeName | DepartmentID |
| 101 | Asha | 10 |
| 102 | Ravi | 20 |
| 103 | Neha | 10 |
- Table: संबंधित रिकॉर्ड का संग्रह।
- Field/Column: किसी विशेष गुण का कॉलम, जैसे EmployeeName।
- Record/Row: एक इकाई से संबंधित विवरण, जैसे कर्मचारी 101 का पूरा रिकॉर्ड।
- Attribute: रिलेशनल शब्दावली में कॉलम का गुण।
- Tuple: रिलेशनल शब्दावली में रो।
इस उदाहरण में 3 रिकॉर्ड और 3 फील्ड हैं। हेडिंग वाली पंक्ति डेटा रिकॉर्ड नहीं है।
Degree: रिलेशन में Attributes की संख्या। Cardinality: रिलेशन में Tuples की संख्या। यहाँ दोनों का मान 3 है।
4. DBMS, RDBMS और डेटा मॉडल
RDBMS का पूरा नाम Relational Database Management System है। यह रिलेशनल मॉडल पर आधारित DBMS है, जिसमें टेबल और उनके बीच संबंध महत्वपूर्ण होते हैं।
संबंध: प्रत्येक RDBMS एक DBMS है, लेकिन प्रत्येक DBMS का रिलेशनल होना आवश्यक नहीं है।
| डेटा मॉडल | मुख्य पहचान |
| Hierarchical | वृक्ष जैसी Parent–Child संरचना। |
| Network | रिकॉर्डों के बीच अनेक लिंक वाली संरचना। |
| Relational | टेबलों में डेटा और की के माध्यम से संबंध। |
MySQL, PostgreSQL, Oracle Database और Microsoft SQL Server रिलेशनल डेटाबेस प्रणालियों के उदाहरण हैं।
5. Primary Key और अन्य महत्वपूर्ण की
Key एक या अधिक कॉलम का समूह हो सकता है, जिसका उपयोग रिकॉर्ड पहचानने या संबंध स्थापित करने में होता है।
| की | अर्थ |
| Super Key | रिकॉर्ड को विशिष्ट रूप से पहचानने वाला कॉलम या कॉलमों का समूह। |
| Candidate Key | ऐसी न्यूनतम Super Key जिसमें कोई अनावश्यक कॉलम न हो। |
| Primary Key | रिकॉर्ड की मुख्य पहचान के लिए चुनी गई Candidate Key। |
| Alternate Key | Primary Key न चुनी गई Candidate Key। |
| Composite Key | एक से अधिक कॉलम से मिलकर बनी की। |
Primary Key के नियम: उसके मान विशिष्ट होते हैं और NULL स्वीकार नहीं होता। एक टेबल में एक Primary Key होती है, लेकिन उसमें अनेक कॉलम शामिल हो सकते हैं।
उदाहरण: Employees में EmployeeID मुख्य पहचान हो सकता है। केवल नाम उपयुक्त पहचान नहीं है, क्योंकि दो कर्मचारियों का नाम समान हो सकता है।
Composite उदाहरण: यदि एक विद्यार्थी प्रत्येक पाठ्यक्रम में केवल एक बार नामांकित हो सकता है, तो Enrolments टेबल में StudentID और CourseID का संयुक्त मान रिकॉर्ड की पहचान कर सकता है।
6. Foreign Key और Referential Integrity
Foreign Key ऐसा कॉलम या कॉलमों का समूह है जो संदर्भित टेबल की Primary Key या किसी उपयुक्त Unique Key से संबंध स्थापित करता है। उसी टेबल के भीतर भी संदर्भ संभव है।
उदाहरण: Departments टेबल में DepartmentID की सहायता से विभाग पहचाने जाते हैं। Employees का DepartmentID उस विभाग का संदर्भ हो सकता है जिसमें कर्मचारी कार्य करता है।
- एक ही विभाग में कई कर्मचारी होने के कारण Foreign Key के मान दोहराए जा सकते हैं।
- यदि NOT NULL जैसा नियम नहीं लगा है, तो Foreign Key में NULL की अनुमति हो सकती है।
- Referential Integrity: संबंधों की वैधता बनाए रखना; जैसे कर्मचारी का दर्ज विभाग संदर्भित विभाग सूची में उपलब्ध होना।
परीक्षा में अंतर: Primary Key मुख्य पहचान देती है। Foreign Key संबंधित रिकॉर्डों के बीच संबंध की वैधता लागू करती है। Foreign Key को हमेशा Unique मानना गलत है।
7. टेबलों के बीच संबंध
| संबंध | उदाहरण |
| One-to-One | एक कर्मचारी और उसकी एक विस्तृत प्रोफाइल। |
| One-to-Many | एक विभाग में अनेक कर्मचारी; प्रत्येक कर्मचारी एक विभाग से जुड़ा हो। |
| Many-to-Many | एक विद्यार्थी अनेक पाठ्यक्रम पढ़े और एक पाठ्यक्रम में अनेक विद्यार्थी हों। |
Many-to-Many संबंध को सामान्यतः Junction Table से दर्शाया जाता है। उदाहरण: Students और Courses के बीच Enrolments टेबल।
8. डेटा टाइप और NULL
- Integer: पूर्णांक, जैसे पुस्तकों की संख्या।
- Decimal: निश्चित दशमलव परिशुद्धता वाले मान, जैसे राशि।
- Text/Character: नाम, पता या पहचान कोड।
- Date/Time: दिनांक और समय।
- Boolean/Yes-No: सत्य-असत्य जैसी स्थिति; नाम और संग्रहण उत्पाद पर निर्भर हैं।
NULL सामान्यतः अज्ञात या अनुपलब्ध मान दर्शाता है। यह संख्या 0 या खाली टेक्स्ट के समान नहीं है।
उदाहरण: Marks में 0 का अर्थ शून्य अंक हो सकता है। Marks में NULL का अर्थ अंक अभी उपलब्ध नहीं होना हो सकता है।
व्यावहारिक समझ: मोबाइल नंबर या अग्रणी शून्य वाला पहचान कोड केवल अंकों से बना होने पर भी Text में रखना उपयुक्त हो सकता है, क्योंकि उसका उद्देश्य गणना नहीं है।
9. SQL और महत्वपूर्ण कमांड
SQL का पूरा नाम Structured Query Language है। इसका उपयोग रिलेशनल डेटाबेस में डेटा प्राप्त करने, बदलने और संरचना पर कार्य करने के लिए होता है। SQL स्वयं DBMS का नाम नहीं है।
| समूह | पूरा नाम | सामान्य उदाहरण |
| DDL | Data Definition Language | CREATE, ALTER, DROP |
| DML | Data Manipulation Language | INSERT, UPDATE, DELETE |
| DQL | Data Query Language | SELECT |
| DCL | Data Control Language | GRANT, REVOKE |
| TCL | Transaction Control Language | COMMIT, ROLLBACK |
वर्गीकरण संबंधी नोट: यह प्रतियोगी परीक्षा पुस्तकों में प्रचलित विभाजन है। सभी उत्पाद इसी तरह वर्गीकरण नहीं करते। उदाहरणतः SELECT को कुछ आधिकारिक दस्तावेज DML में शामिल करते हैं। कमांड का वास्तविक कार्य अवश्य समझें।
10. SELECT, WHERE और ORDER BY
मान लें Candidates टेबल में CandidateID, CandidateName और Marks कॉलम हैं।
SELECT CandidateName, Marks
FROM Candidates
WHERE Marks >= 60
ORDER BY Marks DESC, CandidateID ASC;
- SELECT: कौन-से कॉलम दिखाने हैं।
- FROM: किस टेबल से डेटा लेना है।
- WHERE: कौन-से रिकॉर्ड शर्त पूरी करते हैं।
- ORDER BY: परिणाम किस क्रम में दिखाना है।
- DESC: घटते क्रम में; अधिक अंक पहले।
- ASC: बढ़ते क्रम में; समान अंकों पर छोटी CandidateID पहले।
महत्वपूर्ण तथ्य: ORDER BY के बिना परिणाम का निश्चित क्रम मानना सही नहीं है। Primary Key होने मात्र से SELECT का क्रम सुनिश्चित नहीं होता।
NULL जाँच: अनुपलब्ध अंक खोजने के लिए WHERE Marks IS NULL उपयोग होता है; Marks = NULL सही सामान्य जाँच नहीं है।
11. Aggregate Functions और JOIN
| फंक्शन | कार्य |
| COUNT(*) | परिणाम की सभी रो गिनता है। |
| COUNT(Marks) | Marks में गैर-NULL मान वाली रो गिनता है। |
| SUM(Marks) | अंकों का योग। |
| AVG(Marks) | गैर-NULL अंकों का औसत। |
| MAX(Marks) | सबसे बड़ा मान। |
| MIN(Marks) | सबसे छोटा मान। |
उदाहरण: Marks में 50, NULL और 70 हों, तो COUNT(*) = 3, COUNT(Marks) = 2 और AVG(Marks) = 60 होगा।
GROUP BY समान मान वाले रिकॉर्ड समूहित करता है, जैसे विभागवार कर्मचारियों की संख्या। HAVING समूहों पर शर्त लगाने के लिए उपयोग होता है।
JOIN संबंधित डेटा को क्वेरी परिणाम में जोड़ता है:
- INNER JOIN: दी गई शर्त के अनुसार दोनों ओर मेल खाने वाले रिकॉर्ड।
- LEFT JOIN: बाईं टेबल के सभी रिकॉर्ड और दाईं ओर के मेल खाते रिकॉर्ड; मेल न होने पर दाईं ओर NULL मान।
JOIN करने का अर्थ मूल टेबलों को स्थायी रूप से एक टेबल में बदल देना नहीं है।
12. DELETE, TRUNCATE और DROP
| कमांड | मुख्य कार्य |
| DELETE | रो हटाता है; WHERE से चुनिंदा रिकॉर्ड हटाए जा सकते हैं। |
| TRUNCATE TABLE | पूरी टेबल का डेटा खाली करता है; सामान्य WHERE शर्त नहीं लगती। टेबल संरचना रहती है। |
| DROP TABLE | टेबल ऑब्जेक्ट और उसमें रखा डेटा हटाता है। |
सावधानी: DELETE या UPDATE में WHERE न होने पर सभी रो प्रभावित हो सकती हैं। TRUNCATE को हर DBMS में “कभी Rollback नहीं हो सकता” कहना भी गलत है; Transaction संबंधी व्यवहार उत्पाद पर निर्भर करता है।
13. Redundancy, Normalization, Index और View
- Data Redundancy: एक ही तथ्य का अनावश्यक दोहराव।
- Data Inconsistency: एक ही तथ्य के अलग-अलग रिकॉर्ड में विरोधी मान।
- Normalization: टेबल और उनके संबंध इस तरह व्यवस्थित करना कि अनावश्यक दोहराव और Update संबंधी समस्याएँ कम हों।
- Index: उपयुक्त खोजों को तेज करने वाली सहायक संरचना; इसके लिए अतिरिक्त स्थान और रखरखाव लगता है।
- View: क्वेरी पर आधारित नामित प्रस्तुति; सामान्य View स्वयं परिणाम की अलग स्थायी कॉपी नहीं रखता।
उदाहरण: विभाग का नाम हर कर्मचारी रिकॉर्ड में बार-बार लिखने के स्थान पर Departments टेबल में रखना और Employees में DepartmentID रखना अनावश्यक दोहराव कम कर सकता है।
याद रखें: Index का अर्थ रिकॉर्डों को बढ़ते क्रम में दिखाना नहीं है। परिणाम का क्रम ORDER BY से निर्धारित करें।
14. Transaction, ACID और DBA
Transaction संबंधित डेटाबेस कार्यों की एक तार्किक इकाई है। उदाहरण: पुस्तक जारी करते समय Issue Record जोड़ना और उपलब्ध प्रतियों की संख्या घटाना एक साथ सफल होने चाहिए।
| गुण | सरल अर्थ |
| Atomicity | पूरा कार्य हो या उसका कोई भाग लागू न हो। |
| Consistency | Transaction निर्धारित डेटाबेस नियमों को बनाए रखे। |
| Isolation | समवर्ती Transactions का प्रभाव चुने गए Isolation नियमों के अनुसार नियंत्रित रहे। |
| Durability | सफलतापूर्वक Commit किए गए बदलाव स्थायी बने रहें। |
COMMIT Transaction के बदलाव स्वीकार करता है। ROLLBACK लागू सीमा के भीतर Uncommitted बदलाव वापस करता है।
DBA: Database Administrator। इसके कार्यों में उपयोगकर्ता अनुमति, सुरक्षा, बैकअप, रिकवरी और प्रदर्शन की निगरानी शामिल हैं।
Backup डेटा की पुनर्प्राप्ति योग्य प्रति है। Recovery समस्या के बाद डेटाबेस को उपयुक्त स्थिति में बहाल करने की प्रक्रिया है। केवल बैकअप बनाना पर्याप्त नहीं; उसकी बहाली का परीक्षण भी महत्वपूर्ण है।
15. Microsoft Access और त्वरित पुनरावृत्ति
Microsoft Access एक डेस्कटॉप डेटाबेस एप्लिकेशन है। सामान्य आधुनिक Access डेटाबेस का एक्सटेंशन .accdb और पुराने प्रारूप का .mdb है।
| ऑब्जेक्ट | कार्य |
| Table | डेटा संग्रहित करना। |
| Query | आवश्यक डेटा प्राप्त करना या प्रकार के अनुसार डेटा पर कार्रवाई करना। |
| Form | डेटा देखने, दर्ज करने और संपादित करने का सुविधाजनक इंटरफेस। |
| Report | डेटा को व्यवस्थित प्रस्तुति या प्रिंट योग्य रूप देना। |
- Row = Record; Column = Field।
- Primary Key विशिष्ट और गैर-NULL होती है।
- Foreign Key के मान दोहराए जा सकते हैं।
- WHERE रिकॉर्ड चुनता है; ORDER BY परिणाम क्रमबद्ध करता है।
- COUNT(*) सभी रो गिनता है; COUNT(Column) NULL छोड़ता है।
- DELETE डेटा की रो हटाता है; DROP TABLE टेबल ऑब्जेक्ट हटाता है।
- Form डेटा एंट्री के लिए और Report व्यवस्थित आउटपुट के लिए उपयोगी है।
16. अभ्यास प्रश्न
ये मौलिक अभ्यास प्रश्न हैं, सत्यापित पूर्ववर्ष प्रश्न नहीं। प्रत्येक प्रश्न का एक सही उत्तर है।
प्रश्न 1. डेटाबेस में किसी एक कर्मचारी का पूरा विवरण रखने वाली रो क्या कहलाती है?
A. Field
B. Record
C. Data Type
D. Index
उत्तर और व्याख्या देखें
सही उत्तर: B. Record
एक इकाई से संबंधित विवरण वाली रो Record कहलाती है। किसी विशेष गुण का कॉलम Field कहलाता है।
प्रश्न 2. किसी रिलेशन में 6 Attributes और 25 Tuples हैं। उसकी Degree कितनी है?
A. 25
B. 150
C. 6
D. 31
उत्तर और व्याख्या देखें
सही उत्तर: C. 6
Degree Attributes की संख्या है। Cardinality Tuples की संख्या है।
प्रश्न 3. Primary Key के बारे में कौन-सा कथन सही है?
A. वह विशिष्ट पहचान देती है और NULL स्वीकार नहीं करती।
B. उसमें Duplicate मान अनिवार्य हैं।
C. वह हमेशा केवल एक कॉलम की होती है।
D. वह केवल टेक्स्ट डेटा पर बन सकती है।
उत्तर और व्याख्या देखें
सही उत्तर: A. वह विशिष्ट पहचान देती है और NULL स्वीकार नहीं करती।
Primary Key एक कॉलम या अनेक कॉलम के संयोजन से बन सकती है।
प्रश्न 4. Employees की DepartmentID, Departments की वैध पहचान का संदर्भ रखती है। यह किस प्रकार की की का उदाहरण है?
A. Alternate Key
B. Candidate Key
C. Super Key
D. Foreign Key
उत्तर और व्याख्या देखें
सही उत्तर: D. Foreign Key
Foreign Key संदर्भित रिकॉर्ड के साथ संबंध की वैधता लागू करती है।
प्रश्न 5. एक विभाग में अनेक कर्मचारी हैं और प्रत्येक कर्मचारी एक विभाग से जुड़ा है। विभाग से कर्मचारी का संबंध क्या है?
A. One-to-One
B. One-to-Many
C. Many-to-Many
D. कोई संबंध नहीं
उत्तर और व्याख्या देखें
सही उत्तर: B. One-to-Many
एक विभाग रिकॉर्ड से अनेक कर्मचारी रिकॉर्ड संबंधित हैं।
प्रश्न 6. SELECT के परिणाम को अंकों के घटते क्रम में दिखाने के लिए कौन-सा क्लॉज उपयुक्त है?
A. ORDER BY Marks DESC
B. WHERE Marks ASC
C. GROUP BY Marks DESC
D. SELECT DESC Marks
उत्तर और व्याख्या देखें
सही उत्तर: A. ORDER BY Marks DESC
ORDER BY क्रम निर्धारित करता है और DESC घटते क्रम को दर्शाता है।
प्रश्न 7. Marks में 50, NULL और 70 हैं। COUNT(Marks) क्या लौटाएगा?
A. 3
B. 120
C. 2
D. 60
उत्तर और व्याख्या देखें
सही उत्तर: C. 2
COUNT(Marks) गैर-NULL मान गिनता है। यहाँ 50 और 70, दो मान हैं।
प्रश्न 8. जिन रिकॉर्डों में Marks उपलब्ध नहीं हैं, उन्हें खोजने की सही शर्त कौन-सी है?
A. WHERE Marks = 0
B. WHERE Marks = NULL
C. WHERE Marks = 'NULL'
D. WHERE Marks IS NULL
उत्तर और व्याख्या देखें
सही उत्तर: D. WHERE Marks IS NULL
NULL की जाँच IS NULL से की जाती है। NULL, शून्य या 'NULL' टेक्स्ट नहीं है।
प्रश्न 9. टेबल की संरचना बदले बिना WHERE की शर्त पूरी करने वाले रिकॉर्ड हटाने के लिए कौन-सा कमांड उपयोगी है?
A. DROP TABLE
B. DELETE
C. CREATE TABLE
D. GRANT
उत्तर और व्याख्या देखें
सही उत्तर: B. DELETE
DELETE में WHERE लगाकर चुनी हुई रो हटाई जा सकती हैं।
प्रश्न 10. डेटा का अनावश्यक दोहराव और उससे जुड़ी Update समस्याएँ कम करने के लिए कौन-सी प्रक्रिया उपयोगी है?
A. Normalization
B. Slide Transition
C. Mail Merge
D. Defragmentation
उत्तर और व्याख्या देखें
सही उत्तर: A. Normalization
Normalization टेबल और उनके संबंध को व्यवस्थित करके अनावश्यक दोहराव कम करने में सहायता करता है।
प्रश्न 11. Transaction के “पूरा कार्य या कुछ भी नहीं” सिद्धांत को क्या कहते हैं?
A. Durability
B. Indexing
C. Atomicity
D. Sorting
उत्तर और व्याख्या देखें
सही उत्तर: C. Atomicity
Atomicity के अनुसार Transaction के सभी संबंधित बदलाव एक इकाई के रूप में लागू होते हैं या लागू नहीं होते।
प्रश्न 12. MS Access में कर्मचारियों की मासिक सूची को व्यवस्थित प्रिंट योग्य रूप में प्रस्तुत करने के लिए कौन-सा ऑब्जेक्ट उपयुक्त है?
A. Field
B. Primary Key
C. Relationship
D. Report
उत्तर और व्याख्या देखें
सही उत्तर: D. Report
Report डेटा को व्यवस्थित आउटपुट और प्रिंट योग्य प्रस्तुति देता है।