Module - 1 Notes
Module - 1 Notes
Chapter - 01
Introduction to Databases
1.1 Introduction
1.2 An Example
1.3 Characteristics of the Database Approach
1.4 Actors on the Scene
1.5 Workers behind the Scene
1.6 Advantages of Using the DBMS Approach
1.1 Introduction
▪ A database is a collection of related data.
▪ Data - Raw facts and figures, unprocessed.
▪ Information - Processed data that is meaningful and useful.
Functions of a DBMS
• Define database structure (schema)
• Store and retrieve data
• Update data
• Share data among users
• Security and recovery
1
Database System
Program-Data Independence
• Traditional File Processing:
o Data structure is embedded in application programs.
o Any change in file structure requires modifying all programs that access the file.
o Example: Adding Birth_date to a STUDENT record requires rewriting access programs.
o
2
• DBMS Approach:
o Data structure is stored in the catalog, separate from access programs.
o Programs do not need to change when data structure changes.
o Only the catalog is updated; next time a program refers to it, the new structure is used.
▪ A multiuser DBMS allows multiple users to access the database simultaneously, enabling data
sharing across many applications.
▪ The DBMS uses concurrency control to ensure correct updates when many users access the same data
(e.g., seat reservation systems – OLTP).
3
Key transaction properties:
a) Database Administrators
b) Database Designers
c) End Users
d) System Analysts and Application Programmers (Software Engineers)
b) Database Designer
▪ Identify and model data: Decide what data to store and choose suitable structures before database
implementation.
▪ Gather user requirements: Communicate with all user groups to understand needs and design appropriate
database views.
▪ Key idea: Database designers ensure the database structure correctly supports all users and applications.
End Users: People who access the database for queries, updates, and reports; the database exists mainly for
their use.
4
Categories of End Users:
▪ Casual End Users: Use the database occasionally; need different information each time; use query
interfaces.
▪ Naive (Parametric) End Users: Perform routine tasks using canned transactions (predefined
queries/updates); examples include bank customers, reservation systems, shipping clerks, and social
media users.
▪ Sophisticated End Users: Engineers, scientists, analysts who use DBMS tools to create complex
queries and applications.
▪ Standalone Users: Maintain personal databases using ready-made, menu- or GUI-based software
(e.g., personal finance software).
System Analysts:
▪ Study and determine the requirements of end users, especially naive/parametric users
Programmers:
Note - Analysts design what is needed; programmers build how it works using DBMS features.
b)Tool Developers:
They create software tools that help in database design, modeling, performance monitoring, interfaces,
5
prototyping, simulation, and test data generation. These tools are usually optional and often developed by
independent vendors.
a) Controlling Redundancy
Problems of Data Redundancy
▪ The same data stored in multiple files causes duplicate updates (same change done many times).
▪ It wastes storage space.
▪ It may lead to data inconsistency if different files store different values for the same data.
Database Approach
▪ Each data item is stored only once using data normalization, which saves space and maintains
consistency.
▪ Sometimes controlled redundancy (denormalization) is used to improve query performance by keeping
related data together.
6
▪ Users access the database through accounts and passwords, and the DBMS security and
authorization system controls what each user can do.
d) Providing Storage Structures and Search Techniques for Efficient Query Processing
▪ DBMS must efficiently execute queries and updates since databases are stored on disk.
To speed up searching, DBMS uses indexes (based on tree or hash structures) and buffers/caches to
temporarily keep data in main memory.
▪ The query processing and optimization module selects the most efficient execution plan, while the
DBA decides which indexes to create.
7
g) Representing Complex Relationships among Data
▪ A database contains different types of related data. For example, a student record may be related to
multiple grade reports, and a section may be related to one course and many grade reports.
▪ A DBMS must represent these relationships, allow new relationships to be defined, and retrieve or
update related data efficiently.
▪ Enforcing Standards: DBA can define common data names, formats, and report structures,
improving coordination.
▪ Flexibility: Database structure can be modified or extended without affecting existing data or
applications.
▪ Up-to-Date Information: Updates by one user are immediately visible to others.
▪ Economies of Scale: Centralized data and resources reduce duplication and overall cost.
▪ Reduced Application Development Time: New applications can be developed quickly using the
existing database.
8
Chapter 2
Database System Concepts and Architecture
Categories of Data Models - based on the concepts used to describe database structure.
Comparison Table
It is defined during the database design phase and does not change frequently.
Schema Diagram: displays the structure of each record type but not the actual instances of records.
Database State (Instance) - The database state is the actual data stored at a particular moment in time.
Also called: Snapshot, Current instance, Occurrences
10
Schema vs State
Example:
• Faculty sees: StudentID, Name, Marks
• Accounts sees: StudentID, Name, Fee
Data Independence is the ability to change one level of the database without affecting the next higher level.
The TWO types are :
a) Logical Data Independence
b) Physical Data Independence
12
Example: If we modify the GRADE_REPORT structure, user views that don’t use those changed
fields should continue working.
Comparison Table
Logical Data Independence Physical Data Independence
13
2.3 Database Languages and Interfaces
After database design, different languages are used to define, manipulate, and control the database.
a) View Definition Language (VDL)
b) Data Definition Language (DDL)
c) Storage Definition Language (SDL)
d) Data Manipulation Language (DML)
o High-Level DML (Declarative / Set-Oriented)
o Low-Level DML (Procedural)
In modern DBMS,
• there is no separate Storage Definition Language (SDL).
• Instead, the internal schema (physical storage details) is defined using DBMS functions, storage
parameters, and configuration settings.
14
• These allow the DBA to control how data is stored, such as file organization, indexing, and mapping
data to disk storage.
#include <stdio.h>
int main() {
int emp_id = 101;
15
EXEC SQL UPDATE Employee
SET salary = salary + 1000
WHERE id = :emp_id;
printf("Salary updated\n");
return 0;
}
Summary Table
Language Purpose
c) Forms-Based Interface
• User fills forms to insert or search data
• Designed for naive users
• Used for routine transactions
• Example: Bank deposit form
16
d) Graphical User Interface (GUI)
• Displays schema in diagram form
• User interacts visually
• Often uses menus + forms
g. Speech Input/Output
• Voice-based query system
• Used in banking & travel inquiry systems
DBMS has Two Main Parts. - The top part of the figure refers to the various users of the database environment
and their interfaces. The lower part shows the internal modules of the DBMS responsible for storage of data and
processing of transactions1.
b)Casual Users
• Interactive query - is a query entered directly by a user through a query interface (like SQL prompt) to
retrieve or manipulate data.
18
• Query Compiler - checks the syntax and correctness of a query and converts it into an internal
representation for execution.
• Query Optimizer - concerned with the rearrangement and possible reordering of operations, elimination
of redundancies, and use of efficient search algorithms during execution. Selects the most efficient one
based on cost and performance.
c)Application Programmers
• Pre-compiler - extracts embedded SQL statements from a host language program and sends them to the
DML compiler for processing. Used when SQL (DML) is embedded inside a host programming
language like C, Java, or Python.
• DML Compiler - processes Data Manipulation Language (DML) statements such as SELECT, INSERT,
UPDATE, and DELETE. It processes DML statements, checks for errors, and converts them into
executable instructions for the runtime database processor.
• Host Language Compiler - compiles the host language part of a program and links it with the compiled
DML code to produce an executable program.
d)Parametric Users
• Compiled Transaction (also called Canned Transaction) is a prewritten and precompiled database
program. Supply only input parameters
• Parametric Users are users who execute these predefined transactions by supplying input values.
• Example: Bank withdrawal (account no, amount)
Bottom Part – Internal DBMS Modules - These modules manage storage & processing.
a) The System Catalog (Data Dictionary) –
▪ Repository that stores meta-data about the database structure, constraints, and storage information.
▪ Stores - Table names, Attribute names and data types, Primary keys & foreign keys, Constraints &
Index information
▪ Used by - Query Compiler, Query Optimizer, DBA, Runtime processor
b) Runtime Database Processor - is the module that actually executes database operations.
▪ Executes - Privileged commands, Query execution plans (from optimizer) & Compiled / canned
transactions
19
▪ Works with –
o System Catalog → For schema information
o Stored Data Manager → To access data
o Buffer Manager → For memory management
o Concurrency & Recovery modules → For transaction control
c) Stored Data Manager - module that controls access to data stored on disk.
▪ Manages physical storage of database files
▪ Handles disk read/write operations
▪ Works with the Operating System for low-level I/O
▪ Retrieves and stores records as requested by the Runtime Processor
a)Loading. - is the process of importing existing data files into a database using a loading utility that
reformats the data according to the target database schema. Exampple – CSV file database
b)Backup - process of creating a copy of the database to restore data in case of failure. It can be full backup
or incremental backup.
▪ Why Backup is Needed? - Disk crash, System failure, Natural disasters, Accidental deletion
▪ Full backup – full database is copied
▪ Incremental backup - Only changes made after last backup are stored.
c)Database Storage Reorganization - a utility used to restructure database files to improve performance.
▪ Why is it needed? - Over time, files become fragmented & Access becomes slow
▪ What does it do? - Changes file organization - Sequential → Indexed – Heap → Clustered. Creates new
indexes
20
d)Performance monitoring - utility that collects usage statistics and helps the DBA optimize database
performance.
▪ What does it monitor? - Query execution time, CPU usage, Disk I/O operations.
▪ The DBA uses this information to decide whether to reorganize files, Add or remove indexes
▪ All processing happens on one machine - DBMS functions & Application programs.
▪ Users access system through – Terminals
▪ Terminals only display output, but no processing power.
▪ Used in old systems – where database was stored on mainframe computers
Examples:
File Server → Stores files
Printer Server → Manages printers
Web Server → Hosts websites
21
E-mail Server → Manages emails
Database Server → Manages database
In two-tier architecture, the client handles the user interface and application programs, while the server
handles SQL processing and database management.
22
Three-tier architecture, adds a middle layer between client and database server. The client handles
presentation, the middle tier handles business logic, and the database server manages data storage and
processing.
23
Data Layer (Database Server Tier)
• Stores database
• Executes SQL queries
• Handles transactions
• Manages storage
Advantages
✔ Better security
✔ Better scalability
✔ Easy maintenance
✔ Load balancing possible
n-Tier Architecture
• Extension of three-tier
• Business logic divided further
• Used in ERP & CRM systems
• Middleware connects multiple databases
24
Key-value
▪
• Key-Value Stores:
o Specialized for storing data as key-value pairs.
• Hierarchical & Network DBMS:
o Legacy systems based on hierarchical/tree or network/graph models.
• XML DBMS:
o Use XML tree structure for data storage.
o Can be native XML DBMS or relational DBMS with XML support.
• Centralized DBMS:
o Data and DBMS reside at a single computer site.
o Can support multiple users concurrently.
o All operations are handled by that single site.
• Distributed DBMS (DDBMS):
o Database and DBMS software are spread over multiple sites connected via a network.
o Improves reliability and performance.
o Data replication is common so that a site failure does not make data unavailable.
o Big data systems are often massively distributed, spanning hundreds of sites.
d) Based on Cost
• Open Source / Free DBMS:
o Examples: MySQL, PostgreSQL.
o Supported by third-party vendors for additional services.
• Low-Cost / Personal Versions:
o Some RDBMS offer personal editions under $100.
o May include limited functionality suitable for individuals or small projects.
25
• Commercial / Enterprise Systems:
o Large-scale DBMS sold in modular form with features like:
▪ Distribution and replication
▪ Parallel processing
▪ Mobile support
▪ Configurable parameters
o Sold via licenses:
▪ Site licenses: unlimited use at a location
▪ User-based licenses: limited to number of concurrent users or seats
o Standalone single-user versions (e.g., Microsoft Access) may be sold per copy or bundled with
hardware.
e) Based on Purpose
• General-Purpose DBMS:
o Designed to support a wide range of applications.
o Flexible and can be used for multiple domains without major changes.
• Special-Purpose DBMS:
o Designed for specific applications where performance is critical.
o Cannot be used for other applications without major modifications.
o Examples:
▪ Airline reservation systems
▪ Telephone directory systems
o Often implemented as OLTP (Online Transaction Processing) systems:
▪ Must handle large numbers of concurrent transactions efficiently.
Relational Model
• Represents data as tables (relations).
• Each table can be stored as a separate file.
• Uses SQL for queries.
• Supports limited user views.
• Can incorporate object-oriented features → Object-Relational DBMS.
26
Object Model
• Database defined in terms of objects, their properties, and operations.
• Objects with same structure belong to classes, organized hierarchically or as acyclic graphs.
• Operations are implemented as methods.
• Object-relational systems extend RDBMS to include object concepts.
XML Model
• Uses tree structures; data represented as elements with tags.
• Combines database concepts with document representation.
• Used in native XML DBMSs or as extensions to relational DBMS.
Legacy Models
• Network Model (CODASYL/DBTG):
o Represents data as record types and 1:N relationships (sets).
o Requires record-at-a-time language, often embedded in host languages (e.g., COBOL).
• Hierarchical Model (IMS/DL1):
o Data represented as tree structures.
o No standard DML; DL/1 was widely used.
o Dominated the market from 1965–1985.
27
│ │ ├─ Document-based
│ │ ├─ Graph-based
│ │ ├─ Column-based
│ │ └─ Key-Value
│ ├─ Hierarchical
│ ├─ Network
│ └─ XML DBMS (Native XML or RDBMS with XML support)
│
├─ 2. Based on Number of Users
│ ├─ Single-user
│ └─ Multiuser
│
├─ 3. Based on Distribution of Sites
│ ├─ Centralized DBMS – data at single site
│ └─ Distributed DBMS (DDBMS)
│ ├─ Data replicated across sites
│ └─ Big Data: massively distributed
│
├─ 4. Based on Cost
│ ├─ Open Source / Free – MySQL, PostgreSQL
│ ├─ Low-Cost / Personal Editions – under $100
│ └─ Commercial / Enterprise
│ ├─ Modular features (distribution, replication, parallel processing)
│ ├─ Site license or user-based license
│ ├─ Standalone versions – per copy
│ └─ Extra features at additional cost (data warehousing, mining, etc.)
│
└─ 5. Based on Purpose
├─ General-Purpose DBMS – flexible for multiple applications
└─ Special-Purpose DBMS – optimized for specific applications
├─ Examples: airline reservations, telephone directories
└─ Usually OLTP systems (handle many concurrent transactions)
++++++++++++++++++++++++++++++++++++++++++
28
Chapter 3 Data Modeling Using the Entity Relationship (ER) Model
Topics ::
3.1 High-Level Conceptual Data Models for Database Design
3.2 A Sample Database Application
3.3 Entity Types, Entity Sets, Attributes, and Keys
3.4 Relationship Types, Relationship Sets, Roles, and Structural Constraints
3.5 Weak Entity Types
3.6 Refining the ER Design for the COMPANY Database
3.7 ER Diagrams, Naming Conventions, and Design Issues
Conceptual modeling is a crucial step in designing a successful database application. A database application
includes both the database and the programs that access and update it. Here, the focus is only on database
structure and constraints.
To do this, the Entity–Relationship (ER) model is used. The ER model helps in conceptual database design
by identifying entities, relationships, and constraints, and representing them using ER diagrams, which are
widely used in practice.
Conceptual model focuses on what data is needed, not how it is stored or processed.
b)Conceptual Design - Create a conceptual schema using a high-level model (like ER model).
It describes entities, relationships, and constraints, without worrying about storage or DBMS details. Easy
to understand and useful for discussion with non-technical users.
c) Logical Design (Data Model Mapping) - Convert the conceptual schema into a DBMS-specific model
(usually relational/SQL).Result: logical schema (tables, keys, constraints).
d)Physical Design - Decide how data is stored: files, indexes, access paths, performance tuning.
In parallel, application programs/transactions are implemented
29
Application Program phases
i. Functional Analysis: Identifies what operations users perform on the database—queries, inserts,
updates, and deletes—and the order in which they occur.
ii. Application Program Design: - Focuses on designing programs, forms, menus, and interfaces that
allow users to interact with the database easily and safely.
iii. Transaction Implementation: Implements each operation as a database transaction, ensuring
atomicity, consistency, isolation, and durability (ACID) during execution.
Key idea: Conceptual design focuses on what data and rules, logical design on how data is represented, and
physical design on how data is stored efficiently.
30
3.2 A Sample Database Application
▪ The company is divided into departments, each with a unique name and number, a manager, start date,
and multiple locations.
▪ Each department controls projects, and every project has a unique name, number, and one location.
▪ Employees have personal details stored, work in one department, and may work on multiple projects
with recorded weekly hours.
▪ Each employee has a direct supervisor (another employee).
▪ Dependents of employees are stored for insurance, with personal and relationship details.
Multivalued Attributes: Can have multiple values for the same entity.
Example: College_degrees of a person
31
Constraints: Multivalued attributes may have lower and upper bounds Example: Degrees may be limited to
1–2 values
Unknown Values: Used when the value exists but is not known. It may be missing or Uncertain.
Example: Home_phone not recorded for a person
e) Complex Attributes - is a combination of composite + multivalued attribute. It can be divided into sub-
attributes and can have multiple values.
Example :
Addresses - (12 MG Road, Mysore, KA), (45 Brigade Rd, Bangalore, KA) |
32
33
Entity Types, Entity Sets, Keys, and Value Sets
▪ Entity is a real-world object with independent existence.
▪ Entity type defines a collection (or set) of entities that have the same attributes
▪ An entity set defines a collection of similar entities.
34
▪ Name → alphabetic strings with spaces
▪ Gender → {Male, Female, Other}
35
Role Names and Recursive Relationships
▪ When an entity type participates in a relationship, it plays a specific role.
▪ A role name explains how that entity participates in the relationship.
Example
In the WORKS_FOR relationship:
EMPLOYEE → role = worker
DEPARTMENT → role = employer
Here, role names are optional because the entities are different
Role names are essential when the same entity type participates more than once in a relationship. Such
relationships are called recursive (self-referencing) relationships.
Example: Relationship: SUPERVISION
Entity type: EMPLOYEE (appears twice)
Roles played:
Supervisor (Boss)
Supervisee (Subordinate)
36
Constraints on Binary Relationship Types :
a) Cardinality Ratios for Binary Relationships.
b) Participation Constraints and Existence Dependencies
Cardinality ratio of a binary relationship tells us the maximum number of relationship instances an entity can
participate in.
Possible Cardinality Ratios (Binary) :
1 : 1 → one-to-one
1 : N → one-to-many
N : 1 → many-to-one
M : N → many-to-many
Example - WORKS_FOR binary relationship type between DEPARTMENT:EMPLOYEE is of cardinality ratio
1:N, meaning that each department can be related to (that is, employs) any number of employees (N),9 but an
employee can be related to (work for) at most one department (1).
1 : 1 → one-to-one
One entity is associated with at most one entity of the other type, and vice versa.
Example : MANAGES (1 : 1)
Relationship: MANAGES
Entities: EMPLOYEE — DEPARTMENT
Cardinality: 1 : 1
37
n : 1 → many-to-one is a relationship in which one entity instance can be related to many instances of another
entity, but each instance on the “many” side is related to only one instance on the “one” side.
Example : WORKS_FOR (N : 1)
Relationship: WORKS_FOR
1 : n → one-to-many An entity in A is associated with many entities in B and an entity in B is associated with at
most one entity in A.
38
m : n → many-to-many is a relationship in which one entity can be associated with many entities of another
type, and vice versa.
Example : WORKS_ON (M : N)
Relationship: WORKS_ON
Entities: EMPLOYEE — PROJECT
Cardinality: M : N
39
Participation Constraints and Existence Dependencies
Participation Constraints - defines the minimum number of relationship instances an entity must take part in.
Types of Participation :
a) Total Participation (Existence Dependency)
b) Partial Participation
Example:
If every EMPLOYEE must work for a DEPARTMENT, then
EMPLOYEE has total participation in WORKS_FOR.
40
Partial Participation
▪ Only some entities participate in the relationship
▪ Entity can exist without the relationship
Example:
Not every employee manages a department, so
EMPLOYEE has partial participation in MANAGES..
Relationship Attributes
Attributes of Relationship Types :
• Just like entities, relationship types can also have attributes.
• These attributes describe details of the relationship, not the entity itself.
Examples
WORKS_ON (EMPLOYEE–PROJECT)
• Attribute: Hours
• Meaning: Number of hours an employee works on a project per week
41
MANAGES (EMPLOYEE–DEPARTMENT)
• Attribute: Start_date
• Meaning: Date when an employee started managing a department
Cases ::
1 : 1 Relationship – In this case, Relationship attribute can be moved to either entity.
Example:
▪ MANAGES (1:1)
▪ Start_date can be stored in EMPLOYEE or DEPARTMENT
42
Option 2: Store Relationship Attribute in DEPARTMENT
EMPLOYEE Table DEPARTMENT Table
1 : N Relationship – In this case, Relationship attribute can be moved only to the N-side entity
Example:
▪ WORKS_FOR (Department–Employee)
▪ Start_date → stored in EMPLOYEE
Scenario:
• EMPLOYEE works for a DEPARTMENT (1:N relationship)
• Each DEPARTMENT can have many EMPLOYEES
• Relationship attribute: ReportingDate (when employee joined the department)
43
M : N Relationship – Relationship attributes cannot be moved to any entity. They must remain with the
relationship
Example:
▪ WORKS_ON (M:N)
▪ Hours depends on employee–project combination
Scenario
• EMPLOYEE works on PROJECT
• One employee → many projects
• One project → many employees
• Relationship attribute: HoursWorked
E102 P01 15
Weak Entity - does NOT have its own key & Cannot be identified without another entity
It is identified using both :
a. Owner (identifying) entity
b. Partial key of the weak entity
44
Example : DEPENDENT–EMPLOYEE
Entities :
EMPLOYEE (strong entity, key: EmpID)
DEPENDENT (weak entity)
Attributes of DEPENDENT:
Name (partial key), Birth_date, Sex, Relationship
Note - Two dependents may have the same details, but they are distinguished by which employee they belong to.
Example
EMPLOYEE (Strong Entity) DEPENDENT (Weak Entity)
ER Diagram Notations
45
46
Alternative ER notation for specifying structural constraints on relationships is “(min, max) cardinality
notation”
▪ This replaces traditional 1:1, 1:N, M:N cardinality ratios and single/double-line participation notation.
▪ How it works: For a relationship R between entity type E and R, we associate a pair of integers (min,
max) with the participation of E in R.
Examples
47