📑 Contents

Chapter 8.2: Database Management Systems (DBMS)

9618 AS Computer Science

📚 Learning Objectives
📖 Prior Knowledge Required
🌟 What is a DBMS?

A Database Management System (DBMS) is computer software that interacts with users, other applications, and the database itself to capture and analyze data. It provides users and programmers with a systematic way to create, retrieve, update and manage data.

1. What is a Database Management System?

A Database Management System (DBMS) is a tool to store, edit and organise data in a database. It provides several key features that make it essential for modern data management.

📖 Key Features of a DBMS
CENTRAL DATABASE User 1 User 2 Application Admin User ↓ DBMS manages all access ↓

1.1 Benefits of Using a DBMS

Benefit Description
Integrity The structure of the database can change, but the applications using the data do not need to be changed
Efficiency Avoids data duplication and inconsistency; less storage space taken up because data is shared
Consistency Data is the same, regardless of who is viewing it
Backups It is easy to back up data from one location
Security Data is in a secure central place; different access rights can be assigned to different people
Customisation Applications can be customised to suit the needs of the user
💡 Exam Tip

Remember: A key benefit of DBMS is that it separates applications from data. When people use applications, they call on the data they need. They do not need to use all the data every time they use the database.

2. DBMS vs File-Based Systems

Before DBMS, organisations used file-based systems to store data. These systems had several limitations that DBMS was designed to address.

2.1 Problems with File-Based Systems

⚠️ Key Limitations of File-Based Approach
File-Based System File 1 File 2 File 3 Name Name Name Duplication! DBMS Approach Central Database App 1 App 2 Single Source of Truth DBMS solves ❌ Redundancy ❌ Inconsistency ❌ Dependency ✓ No Redundancy ✓ Consistent Data ✓ Data Independence

2.2 How DBMS Solves These Problems

Issue How DBMS Solves It
Data Redundancy Stores data in separate linked tables using foreign keys, reducing duplication
Data Inconsistency Stores items only once, so updates are seen by all applications
Data Dependency Data is independent of applications; structure changes managed by DBMS
Data Security User accounts and access rights control who can access or change data
Data Management Provides a data dictionary that defines all data elements

3. Data Redundancy and Inconsistency

3.1 Data Redundancy

📖 Definition: Data Redundancy

Data redundancy occurs when the same data point is multiplied across the database and can be found repeated in an unnecessary form. It refers to the duplication of data.

Example: A common example of data redundancy is when a name and address are both present in different columns within a table. If the link between these data points is defined in every single new database entry, it would lead to unnecessary duplication across the entire table.
📝 How DBMS Solves Data Redundancy

3.2 Data Inconsistency

📖 Definition: Data Inconsistency

Data inconsistency is a situation where there are multiple tables within a database that deal with the same data but may receive it from different inputs.

Example: If we have an address of someone in many tables and we change it in only one table but not in another, the problem of data inconsistency occurs. The same person could have different addresses in different files!
📝 How DBMS Solves Data Inconsistency
Without DBMS (Redundant) Customer John London ← Address Orders John Manchester ← Different! ❌ INCONSISTENT DATA DBMS With DBMS (Consistent) Customer John London Orders John_ID → FK ✓ SINGLE SOURCE OF TRUTH FK = Foreign Key links to Customer Address stored once, referenced by all

4. Data Dictionary and Logical Schema

4.1 Data Dictionary

📖 Definition: Data Dictionary

A data dictionary is a central repository that stores metadata (data about data) for a database. It contains information about the structure of the database.

📝 Contents of a Data Dictionary
🌟 Purpose of Data Dictionary

Use of a data dictionary improves integrity of data stored, helping to ensure that it is accurate, complete and consistent. It acts as a blueprint for the entire database structure.

DATA DICTIONARY Table Names Field Names & Types Primary Keys (PK) Foreign Keys (FK) Validation Rules Relationships Used by DBMS Created by Developer

4.2 Logical Schema

📖 Definition: Logical Schema

A logical schema is a data model for a specific database that is independent of the DBMS used to build the database. It describes how relationships will be implemented in the logical structure of the database.

📝 Purpose of Logical Schema
💡 Exam Tip

The logical schema is the conceptual view of the database structure. It shows what data is stored and how tables relate to each other, but NOT how the data is physically stored on disk.

5. Data Integrity

5.1 What is Data Integrity?

📖 Definition: Data Integrity

Data integrity refers to the accuracy, completeness, and consistency of data throughout its lifecycle. It ensures that data remains reliable and trustworthy.

⚠️ Types of Data Integrity

5.2 How DBMS Ensures Data Integrity

📝 Methods to Maintain Data Integrity
Referential Integrity Example CUSTOMERS PK: CustomerID CustomerName Address Phone C001 - John Smith C002 - Jane Doe C003 - Bob Wilson ORDERS PK: OrderID FK: CustomerID OrderDate Total O001 - C001 O002 - C002 O003 - C001 ✓ FK must match PK Cannot delete C001 while O001 exists
💡 Exam Tip: Ensuring Data Integrity

When asked how to ensure data integrity, mention: Validation, Referential Integrity, Input Masks, Data Types, Backup, Access Controls, and Audit Trail.

6. Data Security

6.1 Importance of Data Security

📖 Definition: Data Security

Data security in a DBMS refers to protecting the database from unwanted alteration, corruption, deletion, or unauthorized sharing of data with those who have no right to access it.

📝 How DBMS Ensures Data Security

6.2 Access Levels

One of the challenges of creating a DBMS is managing who can access and change the data. If anyone can edit the database, data could easily become corrupted. It is better to have different levels of access for different users.

User Type Access Level Example Permissions
Customer Limited View own data only, update own profile
Staff Member Moderate View relevant records, add new entries
Account Manager Elevated View financial details, generate reports
Administrator Full Upload/amend entire database, manage users
DATABASE Customer Read Own Staff Read/Write Manager User Reports Admin User Full Access Access Rights
Example: With an online music library, customers should only see their own music, administrators would have access to upload and amend the entire library, and account managers would be able to see the financial details for the customers when required.

7. Database Views

One of the benefits of using a DBMS is that it allows different views of a database. This is useful as different users have different requirements.

7.1 Three Levels of Database Views

View Level Description Used By
External View The view of data used by customers or people who input and view data; simple forms and interfaces End users, customers
Conceptual View Shows how tables are connected; used to plan changes; can be presented using SQL Database designers
Internal View Shows how the computer sees the database; includes file structure, storage, hex/binary references Database programmers
EXTERNAL VIEW Forms, Reports, User Interface SQL Queries CONCEPTUAL VIEW Tables, Relationships, E-R Diagram Mapping INTERNAL VIEW File Structure, Storage, Bytes User DBA Prog ↓ Simplified ↓ Logical ↓ Physical
Example: In a bird watching app, the external view would show a simple form with bird type, time of year, date, and location. The user does not need to see the whole database tables. The conceptual view would show how tables are connected. The internal view would show how data is physically stored.
💡 Exam Tip

Remember the External-Conceptual-Internal hierarchy: External = What users see, Conceptual = What designers plan, Internal = How computers store. A customer does not need to see as much information as the administrator or programmer.

8. Concurrency and ACID

8.1 Concurrency

📖 Definition: Concurrency

Concurrency is when many users are interacting with a system or many changes are being made at once. A DBMS needs to use concurrency, but must prevent two people using the data in a conflicting way.

Example: Two people visiting an online shop might try to buy the final product in store at the same time. The database would need to make sure only one person could buy it.

8.2 ACID Rules

A change in a database is called a transaction. Changes to databases must conform to ACID rules:

📖 ACID Rules Explained
ACID Properties A Atomicity All or Nothing C Consistency Rules Maintained I Isolation No Interference D Durability Permanent Changes Transaction Example Begin Process Validate Commit ❌ Fail = Rollback ✓ Success = Permanent
🧠 Memory Trick: ACID

Think of ACID as the four pillars of reliable transactions:

9. DBMS Software Tools - Developer Interface

9.1 What is the Developer Interface?

📖 Definition: Developer Interface

The developer interface is a tool within DBMS that allows developers to create and manage database objects, write queries, and build user interfaces for the database.

📝 Uses of Developer Interface
DEVELOPER INTERFACE Forms Data Entry Reports Output Queries SQL Tables Structure Scripts Automation Dev DB More flexible than Query-by-Example Allows complex and precise queries
💡 Exam Tip: Developer Interface vs Query-by-Example

The developer interface allows developers to write queries using SQL rather than using query-by-example (QBE) tools. Using SQL allows the developer to create more complex and precise queries to search, update, or manage data.

10. DBMS Software Tools - Query Processor

10.1 What is the Query Processor?

📖 Definition: Query Processor

The query processor is responsible for handling and executing SQL queries. It allows the construction of more complex queries to interrogate the database.

📝 Purpose of Query Processor

10.2 Components of Query Processor

Component Function
DDL Interpreter Interprets Data Definition Language commands (CREATE, ALTER, DROP) and updates the data dictionary
DML Compiler Compiles Data Manipulation Language statements (SELECT, INSERT, UPDATE) into low-level instructions and optimises the query
Query Evaluation Engine Executes the compiled instructions to retrieve or manipulate the actual data in the database
Query Processing Flow SQL Query Type? DDL DDL Interpreter DML DML Compiler Optimise Query Evaluation Engine DATABASE Data Dictionary
⚠️ Key Points to Remember

11. Exam-Style Questions

1. State what is meant by a data dictionary and give one example of an item typically found in a data dictionary. [2 marks]

Answer:

  • A data dictionary is data about the data structure in the database [1 mark]
  • Example items: field name, data type, table name, primary key, foreign key, validation rules, relationships, indexing information [1 mark]

Additional points for deeper understanding: The data dictionary stores metadata, acts as a central repository for all database structure information, helps ensure data integrity by maintaining consistency in definitions.

2. Describe the problems associated with file-based systems that a DBMS addresses. [6 marks]

Answer:

  • Data Redundancy: Same data stored in multiple files, wasting storage space and causing confusion
  • Data Inconsistency: Data may differ between files if one is updated but others are not
  • Data Isolation: Data scattered in various files in different formats, making retrieval difficult
  • Application Dependency: Changing files requires changes in application programs
  • Poor Security: Difficult to apply security constraints across different files
  • Atomicity Issues: Difficult to ensure transactions either fully complete or don't happen at all

Additional points: DBMS solves these by centralizing data, providing data independence, implementing access controls, and supporting transaction management with ACID properties.

3. Explain the purpose of the query processor in a DBMS. [4 marks]

Answer:

  • Enables users to input criteria or conditions for retrieving specific data from the database
  • Conducts searches within the database based on the provided criteria to identify and retrieve relevant data
  • Structures and organizes the retrieved data into a format suitable for presentation to the user
  • Takes a query written in SQL and processes it through DDL interpreter, DML compiler, and query evaluation engine

Additional points: The query processor optimizes queries for better performance, manages different types of SQL statements (DDL and DML), and ensures efficient data retrieval.

4. The database manager is concerned about data integrity. State what is meant by data integrity and give two examples of how the manager can ensure data integrity in the database. [4 marks]

Answer:

Data integrity means ensuring data is consistent, accurate, complete and reliable throughout its lifecycle. [2 marks for definition]

Examples of ensuring data integrity [2 marks for two examples]:

  • Validation - Check data before entry (range checks, format checks)
  • Referential integrity - Ensure foreign keys match existing primary keys
  • Input masks - Ensure correct data format
  • Setting data types - Ensure appropriate data storage
  • Removing redundant data - Reduce inconsistency
  • Backup data - Allow recovery from corruption
  • Access controls - Prevent unauthorized changes
  • Audit trail - Record all changes made
5. Describe how a DBMS can help to make data secure. [5 marks]

Answer:

  • Using usernames and passwords to prevent unauthorized access to the database
  • Using access rights to manage actions authorized users can take (read/write/delete, read only, append only)
  • Using access rights to manage which parts of the database users can access
  • Automatic creation and scheduling of regular backups
  • Encryption of the data stored in the database
  • Automatic creation of an audit trail or activity log to record actions taken by users

Additional points: Security also includes physical security measures, network security, and regular security audits. Different users can be assigned different roles with specific permissions.

11. Exam-Style Questions (Continued)

6. Describe the three levels of database views and explain who would use each level. [6 marks]

Answer:

  • External View: The view used by customers or people who input and view data. Shows simple forms and interfaces. Used by end users. [2 marks]
  • Conceptual View: Shows how tables are connected. Used to plan changes. Can be presented using SQL. Used by database designers. [2 marks]
  • Internal View: Shows how the computer sees the database. Includes file structure, storage, hex/binary references. Used by database programmers. [2 marks]

Additional points: The three-level architecture provides data independence - changes at one level don't necessarily affect other levels. This separation allows for easier maintenance and modification.

7. Explain what is meant by the ACID rules in database transactions. [4 marks]

Answer:

  • Atomicity: The transaction must be completed fully. If it is not completed fully, it will not be recorded. "All or nothing" principle. [1 mark]
  • Consistency: Any change must not break the database. It must be consistent with how it was before the change. [1 mark]
  • Isolation: A transaction must be isolated and not interfere with another transaction. [1 mark]
  • Durability: A transaction must remain in the database permanently once committed. [1 mark]

Additional points: ACID properties ensure reliable processing of database transactions. Without these properties, databases could be left in inconsistent states, leading to data corruption or loss.

8. Describe the benefits of using a DBMS over a file-based approach. [5 marks]

Answer:

  • Integrity: Structure can change without affecting applications using the data
  • Efficiency: Avoids data duplication and inconsistency; less storage space needed
  • Consistency: Data is the same regardless of who is viewing it
  • Backups: Easy to back up data from one central location
  • Security: Data in secure central place with different access rights for different users
  • Customisation: Applications can be customised to suit user needs

Additional points: DBMS also provides query capabilities, concurrent access control, data independence, and standardization of data management practices.

9. Explain the difference between data redundancy and data inconsistency. [4 marks]

Answer:

  • Data Redundancy: Occurs when the same data is stored in multiple places unnecessarily. It refers to the duplication of data, wasting storage space. [2 marks]
  • Data Inconsistency: Occurs when the same data has different values in different places. This happens when data is updated in one location but not in others where it is duplicated. [2 marks]

Additional points: Redundancy causes inconsistency - if the same data is stored in multiple places and one copy is updated, the other copies become inconsistent. DBMS solves both problems by storing data once and using relationships (foreign keys) to link related data.

10. Describe the purpose of the developer interface in a DBMS. [4 marks]

Answer:

  • To create user-friendly features such as forms for data entry
  • To create outputs such as reports showing specific data
  • To create interactive features like buttons and menus for user interaction
  • To allow developers to write queries in SQL rather than using query-by-example

Additional points: The developer interface provides more flexibility than visual query tools, allowing complex and precise queries. It also enables automation through scripts and macros, and supports the creation of complete database applications.

12. Glossary

ACID: Four properties (Atomicity, Consistency, Isolation, Durability) that ensure reliable database transactions.
Atomicity: Property ensuring a transaction is completed fully or not at all.
Concurrency: The ability to handle multiple users interacting with a database simultaneously.
Conceptual View: The logical view showing how database tables are connected.
Data Dictionary: Central repository storing metadata about the database structure.
Data Integrity: The accuracy, completeness, and consistency of data.
Data Inconsistency: When the same data has different values in different locations.
Data Redundancy: Unnecessary duplication of data across a database.
Data Security: Protecting data from unauthorized access, alteration, or deletion.
DBMS: Database Management System - software to create, manage, and interact with databases.
DDL (Data Definition Language): SQL commands to define database structure (CREATE, ALTER, DROP).
Developer Interface: Tool allowing developers to create forms, reports, and SQL queries.
DML (Data Manipulation Language): SQL commands to manipulate data (SELECT, INSERT, UPDATE, DELETE).
Durability: Property ensuring committed transactions remain permanent.
External View: The user-facing view of data (forms, reports).
Foreign Key: A field that links to a primary key in another table.
Internal View: The physical storage view of data (file structure, bytes).
Isolation: Property ensuring transactions don't interfere with each other.
Logical Schema: The overall logical design of a database, independent of physical storage.
Primary Key: A unique identifier for each record in a table.
Query Processor: Component that handles and executes SQL queries.
Referential Integrity: Ensuring foreign keys match existing primary keys.
Transaction: A unit of work in a database that must complete fully or not at all.

13. Exam Success Tips (Part 1)

💡 DBMS Definition - Always Remember
💡 File-Based Problems - Must Know
💡 Data Dictionary Questions
💡 Three Views - External/Conceptual/Internal
💡 ACID Properties

13. Exam Success Tips (Part 2)

💡 Data Security - List Multiple Methods
💡 Data Integrity - How to Ensure
⚠️ Query Processor - Components to Remember
❌ Common Mistakes to Avoid

14. Key Takeaways

📌 DBMS Overview
📌 File-Based vs DBMS
📌 DBMS Features
📌 Database Views
📌 DBMS Tools
📌 ACID Properties
Complete DBMS Overview Users DBMS Query Proc. Dev Interface Data Dict. Security Integrity / ACID DATABASE (Tables/Data)