Introduction to Database System Concepts Notes

Overview of Database Management Systems (DBMS)

A Database Management System (DBMS) consists of a collection of interrelated data and a set of programs designed to access that data. This environment is structured to be both convenient and efficient for users. DBMS technology is fundamental to modern life and is utilized across a vast range of enterprises and applications:

  • Banking: Managing transactions.

  • Airlines: Coordinating reservations and schedules.

  • Universities: Handling registration, grade records, and student information.

  • Sales: Tracking customers, products, and purchases.

  • Online Retailers: managing order tracking and providing customized recommendations.

  • Manufacturing: Controlling production, inventory, orders, and the supply chain.

  • Human Resources: Maintaining employee records, salaries, and tax deductions.

Databases can grow to be very large and influence almost all aspects of human activity.

Shortcomings of Early File-System Data Storage

Before the widespread adoption of DBMS, applications were built directly on top of operating system file systems. This approach led to several significant drawbacks:

  • Data Redundancy and Inconsistency: Information was often duplicated across multiple files with different formats, leading to situations where the same piece of data might have different values in different locations.

  • Difficulty in Accessing Data: Retrieving specific information often required writing a new computer program for every new task.

  • Data Isolation: Data was scattered in various files with different formats, making it hard to integrate.

  • Integrity Problems: Integrity constraints (e.g., the rule that an account balance must be greater than 00) were often hard-coded into application logic. This made it difficult to add new constraints or modify existing ones without changing every program that accessed the data.

  • Atomicity of Updates: Database updates must be atomic, meaning they must happen completely or not at all. If a system failure occurs during a fund transfer from one account to another, the database could be left in an inconsistent state where money is debited from one account but not credited to the other.

  • Concurrent Access Issues: For performance, multiple users must be able to access the database at once. Without controlled access, concurrent updates can lead to inconsistency. For example, if two people see a balance of 100100 and both withdraw 5050 at the same time, the final balance should be 00, but uncontrolled access might result in an incorrect final state.

  • Security Problems: Restricting access so that certain users can see only specific portions of the data is difficult in a standard file system.

Levels of Data Abstraction

Database systems hide complexity from users through several levels of abstraction:

  • Physical Level: The lowest level of abstraction, describing how a record (e.g., an instructor record) is actually stored in memory or on disk.

  • Logical Level: Describes what data is stored in the database and the relationships between that data. For example, an instructor might be defined in the following structure:     type instructor = record\text{type instructor = record}     ID : string;\text{ID : string;}     name : string;\text{name : string;}     dept_name : string;\text{dept\_name : string;}     salary : integer;\text{salary : integer;}     end;\text{end;}

  • View Level: The highest level of abstraction. Application programs hide the details of data types and can also hide specific information (like salaries) for security purposes.

Instances and Schemas

Database systems organize data using structures analogous to types and variables in programming:

  • Logical Schema: The overall logical structure of the entire database. An example is the structure defining bank customers, their accounts, and the relationships between them. This is analogous to the type information of a variable.

  • Physical Schema: The implementation of the database structure at the physical level.

  • Instance: The actual data contained in the database at a specific point in time, analogous to the value of a variable.

  • Physical Data Independence: The ability to modify the physical schema without requiring changes to the logical schema or the application programs that depend on it. This is possible because applications interact with the logical schema through well-defined interfaces.

Data Models

A data model is a collection of conceptual tools used to describe data, data relationships, data semantics, and data constraints. Common models include:

  • Relational Model: Data is organized into tables (relations). This is the most common model used in modern systems.

  • Entity-Relationship (E-R) Model: Used primarily for database design, modeling an enterprise as entities and relationships.

  • Object-based Data Models: These include object-oriented and object-relational models, extending the relational model with object orientation and complex data types.

  • Semistructured Data Model (XML): Used for data interchange, allowing for nested tags and extensible structures defined by the W3C.

  • Older Models: Notable historical models include the Network and Hierarchical models.

Database Languages: DDL and DML

Database systems provided specialized languages for defining and manipulating data:

Data Definition Language (DDL)

DDL is used to specify the database schema. The DDL compiler generates table templates stored in a data dictionary. This dictionary contains metadata (data about data). DDL is also used to define:

  • Integrity Constraints: Such as primary keys (e.g., the ID that uniquely identifies an instructor).

  • Authorizations: Defining who has permission to access which data.

Example DDL statement: create table instructor (\text{create table instructor (} ID char(5),\text{ID char(5),} name varchar(20),\text{name varchar(20),} dept_name varchar(20),\text{dept\_name varchar(20),} salary numeric(8,2))\text{salary numeric(8,2))}

Data Manipulation Language (DML)

DML (also called a query language) is used for accessing and manipulating data organized by the data model. There are two classes:

  • Pure DML: Used for mathematical proofs and optimization (e.g., Relational Algebra, Tuple relational calculus, Domain relational calculus).

  • Commercial DML: Used in production systems, with SQL (Structured Query Language) being the most widely used.

SQL is not Turing machine equivalent. To compute complex functions, it is often embedded in higher-level languages via language extensions or Application Program Interfaces (APIs) like ODBC or JDBC.

Database Engine Internal Components

A database engine is comprised of three primary parts:

  • Storage Manager: This module acts as the interface between low-level data stored on disk and the application programs or queries. It manages interaction with the OS file manager and ensures efficient data storage, retrieval, and updates. Key issues involve storage access, file organization, and indexing/hashing.

  • Query Processor: Handles the execution of data requests in three steps: Parsing and translation, Optimization, and Evaluation. There are often many ways to evaluate a query (different algorithms or equivalent expressions), and the difference in cost (execution time) can be massive. Success depends on maintaining statistical information about relations.

  • Transaction Manager: Ensures the database remains in a consistent state despite system failures (power outages, crashes) or transaction failures. It uses a concurrency-control manager to handle the interaction between simultaneous transactions and maintain consistency.

Database Users and Administrators

Different roles interact with the database system:

  • Naive Users: Interact via application interfaces (e.g., tellers, web users).

  • Application Programmers: Write programs that interact with the database.

  • Sophisticated Users: Use query tools and analysts to interact directly with the database engine.

  • Database Administrators (DBA): Use administration tools to manage the overall system.

Historical Evolution of Databases

  • 1950s - Early 1960s: Reliance on magnetic tapes (sequential access) and punched cards.

  • Late 1960s - 1970s: Development of hard disks for direct access. Network and hierarchical models were common. Ted Codd defined the relational model (winning the Turing Award). IBM's System R and UC Berkeley's Ingres prototypes began.

  • 1980s: Relational prototypes became commercial standards; SQL was standardized. Parallel and distributed systems emerged alongside object-oriented databases.

  • 1990s: Decision support, data mining, and multi-terabyte data warehouses became prominent. Web commerce emerged.

  • Early 2000s: Standards for XML and XQuery were established, along with automated database administration.

  • Later 2000s: Emergence of giant storage systems like Google BigTable, Yahoo PNuts, and Amazon systems.

Systems can be deployed in Centralized, Client-server, Parallel (multi-processor), or Distributed architectures.