Database System Study Notes

UNIT-1: Introduction to Database System Concepts & Introduction to the Relational Model and Database Design using ER model

Course Information

  • Department: Artificial Intelligence

  • Instructor: Tejavath Bala Krishna

Content Overview

  • Introduction to Database System Concepts
      - Database System Applications
      - Purpose of Database Systems
      - View of Data
      - Database Architecture
      - Database Users and Administrators

  • Introduction to the Relational Model and Database Design using ER Model
      - Structure of Relational Databases
      - Database Schema
      - Keys
      - Components of the Entity-Relationship Model
      - Constraints and types of relationships

Course Objectives

  • CO-1: Model Entity-Relationship diagrams for enterprise level databases (L3)

History of Database Systems

1950s and Early 1960s

  • Data Storage: Magnetic tapes were developed for data storage.

  • Processing Requirements: Data processing involved reading data from tapes and writing to new tape processing.

  • Input Mechanism: Punched cards were used for input.

  • Disadvantages:
      - Sequential data reading
      - Insufficient main memory for data loading
      - Required implicit scheduling

Late 1960s and 1970s

  • Technological Advancements: Hard disks developed allowing direct access to data.

  • Data Models: Network and hierarchical data models widely used.

  • Performance: High-performance transaction processing emerged.

1980s

  • Evolution: Research on relational prototypes led to commercial systems.

  • Standardization: SQL becomes the industry standard.

  • Data Systems: Development of parallel and distributed database systems along with object-oriented database systems.

1990s

  • Data Applications: Large decision support and data-mining applications are developed.

  • Data Storage: Multi-terabyte data warehouses become common.

  • Web Commerce: Emergence of web-based commerce platforms.

2000s

  • Standards: Introduction of XML and XQuery standards.

  • Automation: Automated database administration practices become common.

  • Data Systems: Increase in highly parallel database systems and web-scale distributed data storage.

What Is a DBMS?

Definition
  • DBMS: A Database Management System (DBMS) is a software package designed to store and manage databases.

  • Definition: "A software that provides an environment that is both convenient and efficient to use in storing and retrieving the data of an enterprise."

Key Components of a DBMS
  • Entities: Examples include students, courses.

  • Relationships: Example: "Madonna is taking CS564"

Reasons to Use a DBMS
  • Data Independence: Ability to change data structure without affecting applications.

  • Efficient Access: Allows data to be accessed in a proficient manner.

  • Development Efficiency: Reduced application development time.

  • Data Integrity and Security: Ensures data accuracy and safeguards against unauthorized access.

  • Data Administration: Consistency in data management.

  • Concurrent Access: Manages database access by multiple users, including crash recovery.

Tasks Supported by DBMS
  1. Data Definition: Creation, modification, and removal of data definitions.

  2. Data Updation: Insertion, modification, deletion of actual data.

  3. Data Retrieval: Extracting data for various applications.

  4. User Administration: Managing user permissions and performance monitoring.

Characteristics of DBMS
  1. Real World Entity: Manages data for large business organizations securely.

  2. Self-explanatory Nature: Automatically explains all stored information.

  3. Atomicity of Operations (Transactions): All operations transactionally sound.

  4. Concurrent Access without Anomalies: Multiple users can access data simultaneously without issues.

  5. Variety of Structured Data: Can manage diverse data types.

  6. Integrity: Maintains data accuracy and integrity.

  7. Ease of Access: Allows swift searches via simple queries.

  8. SQL and No-SQL Databases:
       - SQL: Data stored in rows and columns.
       - No-SQL: Data in non-tabular formats, e.g., JSON in MongoDB.

  9. ACID Properties:
       - Atomicity: Transactions are all-or-nothing.
       - Consistency: Data remains valid before and after transaction.
       - Isolation: Transactions are isolated from each other.
       - Durability: Completed transactions are stored permanently.

  10. Security: Protects against unauthorized access.

Characteristics of Traditional File Systems

General Characteristics
  • Data Storage: Data kept as independent files.

  • Independence: Files across departments were independent, leading to data redundancy.

  • Implementation: Files developed using languages like COBOL, C, and C++.

  • Costs: High maintenance due to decentralized data storage.

Disadvantages of Traditional File Systems
  1. Distinguished and Isolated Data: Users need multiple files across departments to retrieve information, leading to complex manual checks.

  2. Data Duplication/Redundancy: Same data stored in multiple fields, wasting resources and risking data integrity.

  3. Dependence on Data: Hard-coded formats in programming make changes complex.

  4. Difficult Data Representation: Data must be represented clearly for user understanding.

  5. File Type Variability: Different programming languages yield varying structures.

  6. Low Data Protection: Difficulty in protecting data due to redundancy issues.

  7. Transaction Issues: Lack of ACID compliance resulting in inconsistent states during crashes.

  8. Concurrent Issues: Simultaneous updates by users lead to conflicts.

Advantages of Using a Database System Over Traditional File Systems

  1. Reduction of Redundancy: Data redundancy minimized as each piece of data exists in one location only.

  2. Data Exchange Ease: Simplifies data sharing across multiple users.

  3. Concurrent Data Access: DBMS manages concurrent data access efficiently.

  4. Simplified Data Searching: Queries reduce length of code required to retrieve data.

  5. High Data Reliability: Supports user-defined and built-in data types.

  6. Failure Recovery: ACID principles allow restoration from failures without data loss.

  7. Enhanced Data Protection: Various security methodologies exceed basic password protection.

  8. Data Backup: Backup procedures integrated within the system.

  9. User Interface Variability: A range of interfaces available including graphical and tabular.

  10. Ease of Database Maintenance: Centralized structure simplifies database upkeep.

Disadvantages of DBMS

  1. Cost of Hardware and Software: Requires substantial processing power and memory.

  2. Size Constraints: Takes considerable disk space and memory to operate efficiently.

  3. Complexity: Introduces additional complexity in management and operation.

  4. Higher Impact of Failure: Damage to the central database can result in significant data loss.

Database-System Applications

  • Enterprise Information:
      - Sales: Manages customers, products, purchases.
      - Accounting: Handles payments, receipts, account balances.
      - Human Resources: Manages employee data, payroll taxes, benefits.
      - Manufacturing: Oversees supply chain and production tracking.
      - Online Retailers: Manages sales tracking and product evaluation.

  • Banking and Finance:
      - Banking: Customer, accounts, loans management.
      - Credit Card Transactions: Records purchases and generates statements.
      - Finance: Stores data for stocks and real-time market data.

  • Universities: Tracks student information, course registrations, and grades.

  • Airlines: Manages reservation and scheduling systems.

  • Telecommunication: Maintains call records and billing information.

Purpose of Database Systems

  • View of Data: Provides abstract data representation, hiding physical storage details and focusing solely on information needed by users.

Levels of Data Abstraction in a DBMS

  1. Physical or Internal Level: Describes how data is physically stored.

  2. Logical or Conceptual Level: Describes what data is stored in the database and relationships between data.

  3. View or External Level: Outlines how data is presented to users; different views can be created for different user needs.

Data Independence in DBMS

  • Definition: Ability to change schema without requiring changes to applications.

  • Types:
      1. Physical Data Independence: Changes to physical storage do not affect logical schema.
      2. Logical Data Independence: Changes in logical structure do not affect how applications interact with data.

Database Architecture

  • A DBMS is software that enables data storage, manipulation, and protection.
      - Four Fundamental Purposes:
        1. Defining the information.
        2. Storing the information.
        3. Manipulating the information.
        4. Protecting the information.

Components of Database System

  1. Query Processor: Interprets user requests and executes queries.
       - Subcomponents:
         - DML Compiler: Converts DML statements to machine-level instructions.
         - DDL Interpreter: Processes DDL statements into metadata.
         - Query Evaluation Engine: Executes generated instructions.

  2. Storage Manager: Manages low-level data storage and application interactions.
       - Subcomponents:
         - Transaction Manager: Maintains data consistency across transactions.
         - Authorization and Integrity Manager: Checks user permissions and integrity constraints.
         - Buffer Manager: Handles cache memory for data transfer.

  3. Disk Storage: Includes data files, data dictionary, and indices for optimized data retrieval.

Database Users and Administrators

  • Roles defined by interaction with the DBMS:
      - Database Users: Those who interact with the database for various purposes.
        - Types:
          - Application Programmers: Use DML calls in applications.
          - Sophisticated Users: Developers writing SQL queries.
          - Specialized Users: Create unique applications tailored to specific needs.
          - Naïve Users: Access through pre-written applications or interfaces.

  • Database Administrator (DBA):
      - Responsible for the management of the DBMS.
      - Functions:
        1. Schema definition.
        2. Storage structure definition.
        3. Granting user authorization.
        4. Routine maintenance and error handling.

Introduction to the Relational Model and Database Design using ER Model

  • The relational model is the dominant data model used for commercial data processing applications; praised for its simplicity compared to earlier models.

Structure of Relational Databases

  • Composed of tables, each having unique names that organize and relate data.

  • Key Aspects of Relational Databases:
      1. Tables: Represent entities in data structured as rows (records) and columns (attributes).
      2. Columns: Attributes that define types of data stored.
      3. Rows: Individual records that represent instances of entities.
      4. Relationships: Connections between tables through keys.
      5. Constraints: Rules ensuring data integrity and consistency within the database.

Key Definitions

  1. Relation Schema: Structure defining the attributes and their types, e.g., for a department schema: (deptname, building, budget).

  2. Relation Instance: Set of tuples representing the relation at a specific time.

  3. Degree: Number of attributes in a relation.

  4. Cardinality: Number of tuples in a relation.

  5. NULL Values: Values that are unknown or missing, represented as blank spaces.

  6. Domain: Set of valid atomic values for an attribute.

Keys in Relational Databases

  • Purpose of Keys: Used to uniquely identify tuples and establish relationships between tables.

  1. Primary Key: Unique identifier for a record; cannot contain nulls or duplicates.

  2. Unique Key: Ensures unique values in a column; allows one NULL.

  3. Foreign Key: A link to the primary key of another table, establishing referential integrity.

  4. Candidate Key: Minimal set of attributes that can uniquely identify a tuple; can contain NULLs.

  5. Super Key: Any set of attributes that uniquely identifies a record. It can include extra attributes beyond a candidate key.

  6. Composite Key: Keys that consist of two or more columns to uniquely identify records.

Entity-Relationship (ER) Model

Definition
  • ER Model: High-level data model representing data elements and relationships visually through ER diagrams.

  • Aids in conceptual design and reduces complexity during database design.

Components of ER Diagrams
  1. Entities: Represented as rectangles; they are objects with data attributes.

  2. Attributes: Features of entities represented as ovals (includes key, composite, multivalued, and derived attributes).

  3. Relationships: Represented as diamonds; depict associations between entities (defined by type and degree).

  4. Weak Entities: Entities that depend on other entities for identification, represented with a double rectangle.

Relationship Types and Cardinality
  1. Unary: One entity set involved.

  2. Binary: Two entity sets involved.

  3. n-ary: More than two entity sets involved.

  4. Cardinality Constraints: Defines participation of entities in relationships.
       - One-to-One: Single participation in both entity sets.
       - One-to-Many: One entity can participate in multiple instances of another.
       - Many-to-One: Multiple instances can relate to a single instance of another set.
       - Many-to-Many: All entities can relate to multiple instances.

Steps for Designing ER-Model
  1. Identify entities.

  2. Determine relationships among entities.

  3. Identify key attributes.

  4. Identify relevant attributes.

  5. Create the ER diagram including all attributes.

  6. Review against database requirements.

Sample ER Diagram Components

Includes various entities, attributes, and relationships specific to a university's course structure, illustrating relationships among students, instructors, and courses.

Conclusion

  • Understanding these concepts, structures, and relationships is essential for effective database design and management, enabling the efficient storage and retrieval of data across various applications.