Unit-6: Database Management System

Here’s a detailed explanation based on the content from the image:


1. Introduction to Database

  • A database is an organized collection of data that can be easily accessed, managed, and updated.
  • It stores data efficiently and reduces redundancy.

2. Components of DBMS (Database Management System)

  • Hardware: Physical devices like servers, storage, and client machines.
  • Software: DBMS software (e.g., MySQL, Oracle).
  • Data: Actual data stored in the database.
  • Users:
    • DBA (Database Administrator)
    • Application programmers
    • End-users
  • Procedures: Instructions and rules for designing, using, and managing databases.

3. Structure of DBMS – Logical Structure

  • The logical structure refers to how data is logically organized and perceived by users.

4. Three-Level Architecture (ANSI/SPARC Model)

  1. External Level (View Level): User-specific views of the database.
  2. Conceptual Level (Logical Level): Overall logical structure (entities, relationships).
  3. Internal Level (Physical Level): Physical storage of data.

Mapping Among Levels:

  • External to Conceptual Mapping: Ensures user views are consistent with the logical structure.
  • Conceptual to Internal Mapping: Ensures the logical schema matches the physical storage.

5. Comparison: Traditional File-Based System vs DBMS

AspectFile-Based SystemDBMS
Data RedundancyHighLow
Data ConsistencyHard to maintainEasy
SecurityMinimalStrong
Backup & RecoveryManualAutomated
Data AccessProgram-dependentQuery-based

6. Advantages of DBMS

  • Reduced data redundancy
  • Data consistency
  • Improved data security
  • Backup and recovery
  • Data sharing and multi-user access
  • Data integrity

7. Drawbacks of DBMS

  • High cost (hardware, software, training)
  • Complex to set up and manage
  • Performance can be slower for simple tasks
  • Requires skilled personnel

Here’s a clear and concise explanation based on the second image content:


🔹 Relational Model

📌 What is the Relational Model?

  • A Relational Model represents data in the form of tables (relations).
  • Each table consists of rows (tuples) and columns (attributes).

📌 Relational Key Constraints

  1. Candidate Key: A set of minimal attributes that uniquely identify a tuple.
  2. Primary Key: A selected candidate key that uniquely identifies each record.
  3. Foreign Key: An attribute in one table that refers to the primary key in another table, creating a relationship between tables.

🔹 ER Model (Entity-Relationship Model)

📌 Elements:

  • Entity: Real-world object (e.g., Student, Employee)
  • Attributes: Properties of entities (e.g., Student Name, Age)
  • Relationship: Association between entities (e.g., Enrolled between Student and Course)
  • Cardinality: Number of instances of one entity related to another (1:1, 1:N, N:M)

📌 Types:

  • Entity Types: Strong (with key), Weak (without key)
  • Entity Sets: Collection of similar entities
  • Attributes and Keys: Simple, Composite, Derived, Multi-valued
  • Relationship Types: One-to-one, One-to-many, Many-to-many
  • Relationship Sets: Set of relationships of the same type

🔹 Converting ER Diagram to Relational Tables

Steps:

  1. Entity → Table
  2. Attributes → Columns
  3. Primary Key selection
  4. Relationships → Foreign Keys
  5. Handling Cardinality with appropriate foreign key placement

🔹 Database Schema

  • Definition: A blueprint that defines the structure of the database (tables, relationships, constraints).
  • Includes table definitions, data types, keys, and relationships.

Database Anomalies

Here is an explanation of Database Anomalies in both Hindi and English:

1. Insertion Anomaly (Insertion Anomaly)

  • English: An insertion anomaly occurs when it is difficult to insert new data into the database due to the design of the schema. For example, some data cannot be added without introducing inconsistencies or null values.
  • Hindi: इनसर्शन एनोमली तब होती है जब स्कीमा के डिज़ाइन के कारण नए डेटा को डेटाबेस में डालना मुश्किल हो जाता है। उदाहरण के लिए, कुछ डेटा को जोड़े बिना असंगतता या नल मानों का परिचय होता है।

Example:

  • English: If we have a table that stores employee details along with the department details, and we try to add a new department without adding an employee, the database will not allow it.
  • Hindi: यदि हमारे पास एक तालिका है जो कर्मचारी विवरण और विभाग विवरण दोनों को संग्रहीत करती है, और हम एक नया विभाग जोड़ने की कोशिश करते हैं बिना किसी कर्मचारी को जोड़े, तो डेटाबेस इसे अनुमति नहीं देगा।

2. Update Anomaly (Update Anomaly)

  • English: Update anomaly occurs when a change to data requires multiple updates to ensure consistency, and if all occurrences are not updated, it leads to data inconsistency.
  • Hindi: अपडेट एनोमली तब होती है जब डेटा में परिवर्तन के लिए कई स्थानों पर अपडेट की आवश्यकता होती है, और यदि सभी स्थानों पर अपडेट नहीं किया जाता है, तो इससे डेटा में असंगति होती है।

Example:

  • English: If the address of a company is stored in multiple places and we change the address, we must update all instances. If we miss updating one, the information will be inconsistent.
  • Hindi: यदि एक कंपनी का पता कई स्थानों पर संग्रहित है और हम उस पते को बदलते हैं, तो हमें सभी स्थानों पर उसे अपडेट करना चाहिए। यदि हम एक को अपडेट करना भूल जाते हैं, तो जानकारी में असंगति होगी।

3. Deletion Anomaly (Deletion Anomaly)

  • English: Deletion anomaly occurs when deleting data leads to the unintended loss of other important data stored in the same table.
  • Hindi: डिलीशन एनोमली तब होती है जब डेटा को हटाने से उसी तालिका में संग्रहीत अन्य महत्वपूर्ण डेटा का अप्रत्याशित रूप से नुकसान होता है।

Example:

  • English: If a table stores employee details and their department, deleting an employee’s record might inadvertently delete the department’s information, if that department is associated only with that employee.
  • Hindi: यदि एक तालिका कर्मचारी विवरण और उनके विभाग को संग्रहीत करती है, तो किसी कर्मचारी का रिकॉर्ड हटाने से विभाग की जानकारी अप्रत्याशित रूप से हट सकती है, यदि वह विभाग केवल उसी कर्मचारी से संबंधित हो।

4. Redundancy Anomaly (Redundancy Anomaly)

  • English: Redundancy anomaly occurs when there is unnecessary duplication of data due to improper design, leading to inconsistencies or inefficiencies.
  • Hindi: रिडंडेंसी एनोमली तब होती है जब गलत डिज़ाइन के कारण डेटा की अनावश्यक पुनरावृत्ति होती है, जिससे असंगतता या अक्षमता हो सकती है।

Example:

  • English: If an employee’s address is stored along with each order they place, the address data is repeated for every order, which is inefficient.
  • Hindi: यदि एक कर्मचारी का पता उनके द्वारा किए गए प्रत्येक आदेश के साथ संग्रहीत होता है, तो पता डेटा प्रत्येक आदेश के लिए दोहराया जाता है, जो अप्रभावी है।

5. Normalization Issues (Normalization Problems)

  • English: If the database is not normalized, anomalies like the ones mentioned above are more likely to occur. Normalization is the process of structuring data to reduce redundancy and maintain data integrity.
  • Hindi: यदि डेटाबेस सामान्यीकृत (Normalization) नहीं है, तो ऊपर बताए गए प्रकार की एनोमली होने की संभावना अधिक होती है। सामान्यीकरण डेटा को संरचित करने की प्रक्रिया है जिससे पुनरावृत्ति को कम किया जाता है और डेटा की अखंडता बनाए रखी जाती है।

Example:

  • English: A table that stores both employee and department data may face anomalies like insertion, update, and deletion issues if it is not properly normalized.
  • Hindi: एक तालिका जो कर्मचारी और विभाग दोनों का डेटा संग्रहीत करती है, यदि वह ठीक से सामान्यीकृत नहीं है, तो उसे इनसर्शन, अपडेट और डिलीशन की समस्याएं हो सकती हैं।

Understanding these anomalies is crucial for effective database design. Proper normalization can help minimize these issues, ensuring data integrity and consistency across the database system.

Codd’s 12 Rules:

Here are Codd’s 12 Rules in both Hindi and English:

Codd’s 12 Rules for Relational Databases

1. Information Rule (Information Rule)

  • English: All information in a relational database must be represented in one and only one way—by values in tables.
  • Hindi: एक रिलेशनल डेटाबेस में सभी जानकारी को केवल एक ही तरीके से, यानी तालिकाओं में मानों के रूप में, प्रस्तुत किया जाना चाहिए।

2. Guaranteed Access Rule (Guaranteed Access Rule)

  • English: Every data element (value) in a relational database is guaranteed to be accessible without ambiguity.
  • Hindi: रिलेशनल डेटाबेस में हर डेटा तत्व (मान) को बिना किसी अस्पष्टता के उपलब्ध कराने की गारंटी दी जाती है।

3. Systematic Treatment of Null Values (Systematic Treatment of Null Values)

  • English: Null values (i.e., missing or inapplicable information) must be systematically treated, not ambiguously.
  • Hindi: नल मानों (यानी, गायब या अप्रासंगिक जानकारी) का व्यवस्थित तरीके से उपचार किया जाना चाहिए, न कि अस्पष्ट तरीके से।

4. Dynamic Online Catalog (Dynamic Online Catalog)

  • English: The database should have a catalog that can be dynamically accessed and modified by authorized users, without needing to know the internal structure of the database.
  • Hindi: डेटाबेस में एक कैटलॉग होना चाहिए जिसे प्राधिकृत उपयोगकर्ताओं द्वारा गतिशील रूप से एक्सेस और संशोधित किया जा सके, बिना डेटाबेस की आंतरिक संरचना को जाने।

5. Comprehensive Data Sublanguage Rule (Comprehensive Data Sublanguage Rule)

  • English: A relational database must support at least one language that can express all queries, updates, and data definitions.
  • Hindi: एक रिलेशनल डेटाबेस को कम से कम एक भाषा का समर्थन करना चाहिए जो सभी क्वेरी, अपडेट और डेटा परिभाषाओं को व्यक्त कर सके।

6. View Updating Rule (View Updating Rule)

  • English: All views of the data must be updatable. If a user can view data, they should also be able to modify it.
  • Hindi: डेटा के सभी दृश्य (views) को अपडेट किया जा सकता है। अगर उपयोगकर्ता डेटा को देख सकता है, तो उसे उसे संशोधित भी करना चाहिए।

7. High-Level Insert, Update, and Delete (High-Level Insert, Update, Delete)

  • English: The database must support high-level operations for inserting, updating, and deleting data. These operations should not require low-level programming.
  • Hindi: डेटाबेस को डेटा डालने, अपडेट करने और हटाने के लिए उच्च-स्तरीय ऑपरेशन का समर्थन करना चाहिए। इन ऑपरेशनों के लिए निम्न-स्तरीय प्रोग्रामिंग की आवश्यकता नहीं होनी चाहिए।

8. Physical Data Independence (Physical Data Independence)

  • English: The application’s ability to access data should not be affected by changes in the physical storage of the data.
  • Hindi: डेटा तक पहुँचने की एप्लिकेशन की क्षमता डेटा के भौतिक संग्रहण में होने वाले परिवर्तनों से प्रभावित नहीं होनी चाहिए।

9. Logical Data Independence (Logical Data Independence)

  • English: The ability to change the logical schema without having to change the application’s ability to access data.
  • Hindi: तार्किक स्कीमा को बदलने की क्षमता बिना एप्लिकेशन की डेटा तक पहुँचने की क्षमता को बदले।

10. Integrity Independence (Integrity Independence)

  • English: Integrity constraints (rules that define the correctness of data) must be specified separately from the application programs.
  • Hindi: सत्यता प्रतिबंधों (जो डेटा की सहीता को परिभाषित करते हैं) को एप्लिकेशन प्रोग्राम से अलग से परिभाषित किया जाना चाहिए।

11. Distribution Independence (Distribution Independence)

  • English: The database should not be affected by where data is stored (whether in one place or distributed across multiple locations).
  • Hindi: डेटाबेस को इस बात से प्रभावित नहीं होना चाहिए कि डेटा कहाँ संग्रहीत है (चाहे वह एक स्थान पर हो या विभिन्न स्थानों पर वितरित हो)।

12. Non-subversion Rule (Non-subversion Rule)

  • English: If a relational system has a low-level (non-relational) interface, it must not be able to subvert or bypass the integrity of the database.
  • Hindi: यदि एक रिलेशनल सिस्टम में निम्न-स्तरीय (गैर-रिलेशनल) इंटरफ़ेस है, तो उसे डेटाबेस की सत्यता को कमजोर करने या दरकिनार करने की अनुमति नहीं होनी चाहिए।

These 12 rules form the foundation for Codd’s theory on relational database systems and help ensure that databases function in a consistent, flexible, and efficient way.