Docsity

Database Systems and Architectures, Study Guides, Projects, Research of Database Management Systems (DBMS)

Toggle sidebar
bg1
DATABASE SYSTEMS
Complete Learning Guide
Unit-1: Comprehensive Study Material
Topics Covered:
• Database System Architecture
• Data Abstraction & Independence
• Views, Models & Schemas
• Three-Level Architecture
• Client/Server Architecture
• Data Definition Language (DDL)
• Data Manipulation Language (DML)
• Data Models (ER, Network, Relational, OOP)
• Integrity Constraints
• Database Design & Administration
Note: This guide explains complex concepts in simple, easy-to-understand language with real-world examples.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Database Systems and Architectures and more Study Guides, Projects, Research Database Management Systems (DBMS) in PDF only on Docsity!

DATABASE SYSTEMS

Complete Learning Guide

Unit-1: Comprehensive Study Material

Topics Covered:

  • Database System Architecture
  • Data Abstraction & Independence
  • Views, Models & Schemas
  • Three-Level Architecture
  • Client/Server Architecture
  • Data Definition Language (DDL)
  • Data Manipulation Language (DML)
  • Data Models (ER, Network, Relational, OOP)
  • Integrity Constraints
  • Database Design & Administration

Note: This guide explains complex concepts in simple, easy-to-understand language with real-world examples.

TABLE OF CONTENTS

  1. Introduction to Database Systems
  2. Database System Architecture
  3. Data Abstraction and Data Independence
  4. Views of Data and Data Models
  5. Schemas and Instances
  6. Three-Level Architecture of Database
  7. Client/Server Architecture
  8. Data Definition Language (DDL)
  9. Data Manipulation Language (DML)
  10. Entity-Relationship (ER) Model
  11. Network and Relational Models
  12. Object-Oriented Data Model
  13. Integrity Constraints
  14. Database Administrator Responsibilities
  15. Database Design Issues

2. DATABASE SYSTEM ARCHITECTURE

What is Database Architecture?

Database architecture refers to the overall design and structure of a database system. It defines how the database is organized, how data flows through the system, and how different components interact with each other.

Components of Database System:

Component Purpose

Query Processor Understands and processes user requests Optimization Engines Finds the best way to execute queries Classic Query Engine Executes the optimized queries Buffer Manager Manages data in memory Storage Manager Handles data storage on disk Transaction Manager Ensures data consistency

Simple Diagram: Database System Architecture

User → Query Interface → Query Processor → Optimization Engine → Classic Query Engine → Buffer Manager → Storage Manager → Disk (Database Files)

3. DATA ABSTRACTION AND DATA INDEPENDENCE

What is Data Abstraction?

Data abstraction means hiding the complex details of how data is stored and managed, showing users only the information they need. It's like a car—you drive it without knowing how the engine works!

Example of Data Abstraction: When you use a mobile banking app, you see your account balance, transaction history, and can transfer money. You don't see how the data is actually stored in the bank's database or how the security encryption works—these are hidden from you.

What is Data Independence?

Data independence means the ability to change the physical storage of data without affecting the programs or applications that use that data. It separates 'what' the data is from 'where' and 'how' it is stored.

Two Types of Data Independence:

1. Physical Data Independence:

The ability to change the physical storage details (like changing from hard disk to solid-state drive) without affecting the application programs or the way users access the data.

2. Logical Data Independence:

The ability to add new data items or modify the logical structure (like adding a 'phone number' field to a student record) without affecting existing applications.

Benefit: Developers can change how data is stored without rewriting application code. This saves time and money!

5. SCHEMAS AND INSTANCES

What is a Schema?

A schema is the 'structure' or 'blueprint' of a database. It defines what type of data will be stored, the names of fields, and the rules about that data. The schema tells us 'WHAT' will be stored, not the actual data itself.

What is an Instance?

An instance is the actual data stored in the database at a particular moment. It is the real values that match the schema. The instance is 'WHO' or 'WHAT' is actually stored.

Example: Student Database

Schema (Structure) Instance (Real Data)

STUDENT(RollNo, Name, Age, Grade) 101, 'Amit Kumar', 15, 'A'

  • RollNo is a number 105, 'Priya Singh', 16, 'A+'
  • Name is text 110, 'Raj Patel', 15, 'B'
  • Age is a number
  • Grade is text

Key Difference: Schema is like a form's template (never changes), while instance is the completed filled form (changes every day as new data is added).

6. THREE-LEVEL ARCHITECTURE OF DATABASE

Introduction

The three-level architecture divides a database system into three levels, each with its own view and purpose. This separation makes the database more flexible and easier to maintain.

Level 1: Internal Level (Physical Level)

What it is: How data is actually stored on the computer's hard drive. Who works here: Database administrators and system programmers. Details it shows: File organization, storage format, disk space, indexing methods.

Example: The database is stored in a file named 'school.db' on the hard drive. The data is organized in blocks for fast retrieval. This physical reality is hidden from end users.

Level 2: Conceptual Level (Logical Level)

What it is: The overall logical structure of the entire database. Who works here: Database designers and administrators. Details it shows: What data exists, how entities relate, constraints, types of data.

Example: The database has a STUDENT table with fields like RollNo, Name, Age. It has a MARKS table with StudentID, Subject, Score. These tables have a relationship. No details about actual storage.

Level 3: External Level (View Level)

What it is: What individual users see and work with (different views). Who works here: End users and application developers. Details it shows: Only the data relevant to that user, hiding unnecessary details.

Example: A student sees only their own marks and personal information. A teacher sees marks of their students. They don't see how data is stored or the entire database structure.

Visual Representation:

EXTERNAL LEVEL (Views) → User1, User2, User ↓ (Mapping) CONCEPTUAL LEVEL (Logical) → Database Structure & Relationships ↓ (Mapping) INTERNAL LEVEL (Physical) → Storage on Hard Drive

Benefit of Three Levels: Each level can be modified independently. If storage method changes, it doesn't affect users or application programs!

8. DATA DEFINITION LANGUAGE (DDL)

What is DDL?

DDL (Data Definition Language) is a set of commands used to create, modify, and delete the structure of database objects like tables, indexes, and schemas. DDL commands define 'WHAT' will be stored.

Common DDL Commands:

Command Purpose Example CREATE Creates a new table CREATE TABLE STUDENT(RollNo, Name) ALTER Modifies table structure ALTER TABLE STUDENT ADD Age DROP Deletes a table DROP TABLE STUDENT TRUNCATE Removes all records TRUNCATE TABLE STUDENT RENAME Renames a table RENAME TABLE STUDENT TO PUPILS

CREATE TABLE - Detailed Example:

CREATE TABLE STUDENT ( RollNo INT PRIMARY KEY, Name VARCHAR(50), Age INT, Grade VARCHAR(1) );

Explanation: This creates a STUDENT table with 4 columns. RollNo is the primary key (unique identifier). Name can store up to 50 characters. Age and Grade are also defined.

Key Point: DDL commands are used to create and structure the database. They define the 'template' or 'skeleton' of the database.

9. DATA MANIPULATION LANGUAGE (DML)

What is DML?

DML (Data Manipulation Language) is a set of commands used to insert, retrieve, update, and delete actual data in a database. DML commands work with the 'instances' (actual data), not the structure.

Main DML Commands:

Command Purpose

SELECT Retrieve/Read data from a table INSERT Add new records/rows to a table UPDATE Modify existing records DELETE Remove records from a table

Examples:

1. INSERT - Adding new data:

INSERT INTO STUDENT VALUES(101, 'Amit Kumar', 15, 'A'); This adds a new student record to the STUDENT table. The values are: RollNo=101, Name='Amit Kumar', Age=15, Grade='A'

2. SELECT - Reading data:

SELECT * FROM STUDENT WHERE Grade='A'; This retrieves all students who have grade 'A'. The asterisk (*) means 'all columns'.

3. UPDATE - Modifying data:

UPDATE STUDENT SET Grade='A+' WHERE RollNo=101; This changes the grade of student with RollNo 101 from 'A' to 'A+'.

4. DELETE - Removing data:

DELETE FROM STUDENT WHERE RollNo=101; This removes the student record with RollNo 101 from the database.

11. NETWORK AND RELATIONAL MODELS

Network Data Model

What is Network Model? The network model represents data as a collection of records (like a table row) and the relationships between records are represented using pointers (links). It's like a web where everything is connected to everything else.

Characteristics of Network Model:

  • Many-to-many relationships are supported
  • Complex relationships can be represented
  • Navigation through the database can be complex
  • More suitable for complex data relationships

Example: A STUDENT can have many TEACHERS, and a TEACHER can have many STUDENTS. This many-to-many relationship is naturally represented in the network model.

Relational Data Model

What is Relational Model? The relational model represents data as a collection of tables (called relations). Each table has rows (tuples) and columns (attributes). This is the most popular and widely used model today.

Why is Relational Model Popular?

  • Simple and easy to understand (tables are familiar)
  • Powerful query language (SQL)
  • Mathematical foundation is strong
  • Used in almost all commercial databases (MySQL, PostgreSQL, Oracle)

Example:

RollNo Name Age 101 Amit 15 102 Priya 16 103 Raj 15

The table above shows a STUDENT table in the relational model. Each row represents one student, each column represents an attribute.

Comparison: Network model is more complex but can handle very complex relationships. Relational model is simpler and more user-friendly, which is why it's preferred in most applications.

12. OBJECT-ORIENTED DATA MODEL

What is Object-Oriented Model?

The object-oriented (OO) model treats data as 'objects' which contain both data (attributes) and methods (functions/operations). Each object has a unique identity, state, and behavior. This is different from traditional models that only store data.

Key Concepts:

1. Object: An instance of a class with both data and methods.

Example: A STUDENT object has data like name, age, and methods like 'calculateGPA()' or 'enrollInCourse()'

2. Class: A template or blueprint for creating objects.

Example: The STUDENT class defines the structure of a student object.

3. Encapsulation: Bundling data and methods together while hiding implementation details. 4. Inheritance: A class can inherit properties from another class.

Example: TEACHER class can inherit properties from a PERSON class.

5. Polymorphism: The ability to use the same operation name with different meanings.

Simple Example: Class STUDENT { Data: RollNo, Name, Age, Marks Methods: getMarks(), updateMarks(), calculatePercentage() }

When to Use OO Model?

  • When the database has complex operations
  • When you need to store both data and behavior
  • For sophisticated applications like multimedia databases
  • When inheritance and relationships are complex

Note: OO model is more complex than relational model and is used in specialized applications. For most business applications, the relational model is still preferred.

14. DATABASE ADMINISTRATOR RESPONSIBILITIES

Who is a Database Administrator (DBA)?

A Database Administrator (DBA) is a professional responsible for managing, maintaining, and securing the database. They act as the 'guardian' of the database, ensuring it runs smoothly and safely.

Key Responsibilities:

1. Database Design: Plan and create the database structure before building it 2. Performance Tuning: Ensure the database runs quickly and efficiently 3. Backup & Recovery: Create regular backups and restore data if something goes wrong 4. Security: Protect data from unauthorized access using passwords and permissions 5. User Management: Create user accounts and control who can access what data 6. Monitoring: Check the database regularly to ensure it's working properly 7. Updates & Maintenance: Apply updates and fix problems when they occur 8. Documentation: Maintain records of database structure and changes 9. Troubleshooting: Identify and fix problems when the database isn't working 10. Optimization: Improve database performance and storage efficiency

Example: A DBA's Daily Work Morning: Check if all systems are running normally. Afternoon: A new user needs database access—set up their account. Evening: Create a backup of all data. If data ever gets corrupted, the DBA can restore it from the backup.

Importance: A good DBA ensures the database is always available, data is secure, and systems run efficiently. Without a DBA, the database could fail, causing all business operations to stop!

15. DATABASE DESIGN ISSUES

What are Database Design Issues?

Database design issues are challenges and problems that arise when designing and creating a database. Planning carefully during design saves time and problems later.

Common Design Issues:

1. Redundancy (Duplication):

Problem: Storing the same data in multiple places wastes space and causes inconsistency. When data is updated in one place but not another, conflicts arise.

Solution: Design tables carefully to minimize duplication using proper normalization techniques.

2. Inconsistency:

Problem: Same data having different values in different places. Example: A student's name is 'Amit' in one table but 'Ameet' in another.

Solution: Use integrity constraints and proper relationships to ensure data consistency.

3. Update Anomaly:

Problem: If you need to update one piece of data, you might have to update it in many places, increasing the risk of errors.

Solution: Store each data item in only one place.

4. Deletion Anomaly:

Problem: Deleting one record might accidentally delete important related data.

Solution: Use proper relationships and foreign keys to prevent accidental deletion.

5. Insertion Anomaly:

Problem: You might not be able to insert a record because related data doesn't exist yet.

Solution: Design tables so that each type of data is stored separately.

Real-World Example: If a school stores student name and teacher name in the same table, and later a teacher changes their name, the system might not know which entries to update. This can lead to confusion. It's better to keep STUDENT and TEACHER in separate tables with only StudentID and TeacherID linked.

How to Avoid These Issues:

  • Use the ER model to plan the database carefully
  • Normalize the database (organize tables to reduce redundancy)
  • Use primary keys and foreign keys properly
  • Test the database thoroughly before going live
  • Document all decisions and changes