0% found this document useful (0 votes)
25 views

Introduction To Database

The document discusses database systems and their purpose. Database systems are used to manage large, complex collections of valuable data accessed by multiple users. They address issues like data redundancy, inconsistent access, and concurrent access that arise from traditional file-based data storage. The relational model represents data as tables with rows and columns and provides different levels of abstraction for users.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Introduction To Database

The document discusses database systems and their purpose. Database systems are used to manage large, complex collections of valuable data accessed by multiple users. They address issues like data redundancy, inconsistent access, and concurrent access that arise from traditional file-based data storage. The relational model represents data as tables with rows and columns and provides different levels of abstraction for users.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

Introduction to Database

Database System Concepts, 7th Ed.


©Silberschatz, Korth and Sudarshan
See www.db-book.com for conditions on re-use
Database Systems

• DBMS contains information about a particular enterprise


• Collection of interrelated data
• Set of programs to access the data
• An environment that is both convenient and efficient to use
• Database systems are used to manage collections of data that are:
• Highly valuable
• Relatively large
• Accessed by multiple users and applications, often at the same
time.
• A modern database system is a complex software system whose
task is to manage a ______, ________ collection of data.
• Databases touch all aspects of our lives

1.2
Database Systems

• DBMS contains information about a particular enterprise


• Collection of interrelated data
• Set of programs to access the data
• An environment that is both convenient and efficient to use
• Database systems are used to manage collections of data that are:
• Highly valuable
• Relatively large
• Accessed by multiple users and applications, often at the same
time.
• A modern database system is a complex software system whose
task is to manage a large, complex collection of data.
• Databases touch all aspects of our lives

1.3
Database Applications Examples

• Enterprise Information
• Sales: customers, products, purchases
• Accounting: payments, receipts, assets
• Human Resources: Information about employees, salaries, payroll
taxes.
• Manufacturing: management of production, inventory, orders, supply
chain.
• Banking and finance
• customer information, accounts, loans, and banking transactions.
• Credit card transactions
• Finance: sales and purchases of financial instruments (e.g., stocks
and bonds; storing real-time market data
• Universities: registration, grades

1.4
Database Applications Examples (Cont.)

• Airlines: reservations, schedules


• Telecommunication: records of calls, texts, and data usage, generating
monthly bills, maintaining balances on prepaid calling cards
• Web-based services
• Online retailers: order tracking, customized recommendations
• Online advertisements
• Document databases
• Navigation systems: For maintaining the locations of varies places of
interest along with the exact routes of roads, train systems, buses, etc.

1.5
Purpose of Database Systems
In the early days, database applications were built directly on top of file
systems, which leads to:
• Data redundancy and inconsistency:
data is stored in multiple file formats resulting in duplication of
information in different files
• Difficulty in accessing data
Need to write a new program to carry out each new task
• Data isolation
Multiple files and formats
• Integrity problems
Integrity constraints (e.g., account balance > 0) become “buried”
in program code rather than being stated explicitly
Hard to add new constraints or change existing ones

1.6
Purpose of Database Systems
In the early days, database applications were built directly on top of file
systems, which leads to:
• _______________:
data is stored in multiple file formats resulting in duplication of
information in different files
• ________________:
Need to write a new program to carry out each new task
• ________________:
Multiple files and formats
• ________________:
Integrity constraints (e.g., account balance > 0) become “buried” in
program code rather than being stated explicitly
Hard to add new constraints or change existing ones

1.7
Purpose of Database Systems (Cont.)

• Atomicity of updates
• Failures may leave database in an inconsistent state with partial
updates carried out
• Example: Transfer of funds from one account to another should either
complete or not happen at all
• Concurrent access by multiple users
• Concurrent access needed for performance
• Uncontrolled concurrent accesses can lead to inconsistencies
• Ex: Two people reading a balance (say 100) and updating it by
withdrawing money (say 50 each) at the same time
• Security problems
• Hard to provide user access to some, but not all, data

Database systems offer solutions to all the above problems

1.8
Purpose of Database Systems (Cont.)

• __________of updates
• Failures may leave database in an inconsistent state with partial
updates carried out
• Example: Transfer of funds from one account to another should either
complete or not happen at all
• ___________ access by multiple users
• _________ access needed for performance
• Uncontrolled concurrent accesses can lead to inconsistencies
• Ex: Two people reading a balance (say 100) and updating it by
withdrawing money (say 50 each) at the same time
• ___________ problems
• Hard to provide user access to some, but not all, data

Database systems offer solutions to all the above problems

1.9
University Database Example
• In this text we will be using a university database to illustrate all the
concepts
• Data consists of information about:
• Students
• Instructors
• Classes
• Application program examples:
• Add new students, instructors, and courses
• Register students for courses, and generate class rosters
• Assign grades to students, compute grade point averages (GPA) and
generate transcripts

1.10
1.11
View of Data
• A database system is a collection of interrelated _______and a set of
________ that allow users to access and modify these data.
• A major purpose of a database system is to provide users with an
abstract view of the data.
• Data models
• A collection of conceptual tools for describing data, data
relationships, and consistency constraints.
• Data abstraction
• Hide the complexity of data structures to represent data in the
database from users through several levels of data abstraction.

1.12
View of Data
• A database system is a collection of interrelated data and a set of
__________ that allow users to access and modify these data.
• A major purpose of a database system is to provide users with an
abstract view of the data.
• Data models
• A collection of conceptual tools for describing data, data
relationships, and consistency constraints.
• Data abstraction
• Hide the complexity of data structures to represent data in the
database from users through several levels of data abstraction.

1.13
View of Data
• A database system is a collection of interrelated data and a set of
programs that allow users to access and modify these data.
• A major purpose of a database system is to provide users with an
abstract view of the data.
• Data models
• A collection of conceptual tools for describing data, data
relationships, and consistency constraints.
• Data abstraction
• Hide the complexity of data structures to represent data in the
database from users through several levels of data abstraction.

1.14
Data Models
• A collection of tools for describing
• Data
• Data ________
• Data ________
• Relational model
• Object-based data models
• Other older models:
• Network model
• Hierarchical model

1.15
Data Models
• A collection of tools for describing
• Data
• Data relationships
• Data constraints
• Relational model
• Object-based data models
• Other older models:
• Network model
• Hierarchical model

1.16
1.17
1.18
1.19
1.20
1.21
1.22
1.23
Relational Model
• All the data is stored in various ________.
• Example of tabular data in the relational model.
Columns

Rows

Ted Codd
Turing Award 1981

1.24
Relational Model
• All the data is stored in various tables.
• Example of tabular data in the relational model.
Columns

Rows

Ted Codd
Turing Award 1981

1.25
ACM A.M. Turing Award

1.26
Ted Codd
Turing Award 1981

Ted Codd (19 August 1923 – 18 April 2003) was an English computer scientist who, while
working for IBM, invented the relational model for database management, the theoretical basis
for relational databases and relational database management systems. He made other valuable
contributions to computer science, but the relational model, a very influential general theory of
data management, remains his most mentioned, analyzed and celebrated achievement

https://www.seas.upenn.edu/~zives/03f/cis550/codd.pdf
1.27
Levels of Abstraction

• _________:describes how a record (e.g., instructor) is stored.


• _________: describes data stored in database, and the relationships
among the data.
type instructor = record
ID : string;
name : string;
dept_name : string;
salary : integer;
end;
• __________: application programs hide details of data types.
___________can also hide information (such as an employee’s salary)
for security purposes.

1.28
Levels of Abstraction

• Physical level: describes how a record (e.g., instructor) is stored.


• _____________: describes data stored in database, and the
relationships among the data.
type instructor = record
ID : string;
name : string;
dept_name : string;
salary : integer;
end;
• ____________: application programs hide details of data types. Views
can also hide information (such as an employee’s salary) for security
purposes.

1.29
Levels of Abstraction

• Physical level: describes how a record (e.g., instructor) is stored.


• Logical level: describes data stored in database, and the relationships
among the data.
type instructor = record
ID : string;
name : string;
dept_name : string;
salary : integer;
end;
• ____________: application programs hide details of data types. Views
can also hide information (such as an employee’s salary) for security
purposes.

1.30
Levels of Abstraction

• Physical level: describes how a record (e.g., instructor) is stored.


• Logical level: describes data stored in database, and the relationships
among the data.
type instructor = record
ID : string;
name : string;
dept_name : string;
salary : integer;
end;
• View level: application programs hide details of data types. Views
can also hide information (such as an employee’s salary) for security
purposes.

1.31
Instances and Schemas

• Logical Schema – the overall logical structure of the database


• Example: The database consists of information about a set of
customers and accounts in a bank and the relationship between
them
• Physical schema – the overall physical structure of the database
• Instance – the actual content of the database at a particular point in
time

1.32
Data Independence

• Physical Data Independence – the ability to modify the physical


schema without changing the logical schema
• Logical Data Independence – the ability to modify the logical schema
without changing the physical schema

• Applications depend on the logical schema.


• In general, the interfaces between the various levels and
components should be well defined so that changes in some parts
do not seriously influence others.

1.33
Data Definition Language (DDL)

• Specification notation for defining the database schema


Example: create table instructor (
ID char(5),
name varchar(20),
dept_name varchar(20),
salary numeric(8,2))
• DDL compiler generates a set of table templates stored in a data
dictionary
• Data dictionary contains metadata (i.e., ______________)

1.34
Data Definition Language (DDL)
• Specification notation for defining the database schema
Example: create table instructor (
ID char(5),
name varchar(20),
dept_name varchar(20),
salary numeric(8,2))
• DDL compiler generates a set of table templates stored in a data dictionary
• Data dictionary contains metadata (i.e., data about data)
Key Words:
• CREATE DATABASE
• ALTER DATABASE
• CREATE TABLE
• ALTER TABLE
• DROP TABLE
• CREATE INDEX
• DROP INDEX
1.35
Data Manipulation Language (DML)

• Language for accessing and updating the data organized by the


appropriate data model
• DML also known as query language
• There are basically two types of data-manipulation language
• Procedural DML -- require a user to specify what data are needed
and how to get those data.
• Declarative DML -- require a user to specify what data are
needed without specifying how to get those data.
• Declarative DMLs are usually easier to learn and use than are
procedural DMLs.
• Declarative DMLs are also referred to as non-procedural DMLs

1.36
SQL Query Language

• SQL query language is nonprocedural. A query takes as input several


tables (possibly only one) and always returns a single table.
• Example to find all instructors in Comp. Sci. dept
select name
from instructor
where dept_name = 'Comp. Sci.’

1.37
SQL Query Language

• SQL query language is nonprocedural. A query takes as input several


tables (possibly only one) and always returns a single table.
• Example to find all instructors in Comp. Sci. dept
select name
from instructor
where dept_name = 'Comp. Sci.’

Key Words:
• SELECT: retrieve data from the database
• INSERT: insert data into a table
• UPDATE: update existing data within a table
• DELETE: deletes records from a table,
space for the records remain

1.38
Data Control Language (DCL)

A Data Control Language is a syntax similar to a computer programming


language used to control access to data stored in a database.

Key Words:

• GRANT: allow specified users to perform specified tasks.


• REVOKE: cancel previously granted or denied permissions.

1.39
Transaction Control Language (TCL)

Transaction Control Language commands are used to manage transactions


in the database. These are used to manage the changes made by DML-
statements.

Key Words:

• COMMIT: Commit command is used to permanently save any transaction


into the database.

• ROLLBACK: This command restores the database to last committed state.


It is also used with savepoint command to jump to a savepoint in a
transaction.

• SAVEPOINT: Savepoint command is used to temporarily save a transaction


so that you can rollback to that point whenever necessary.
1.40
Database Design

The process of designing the general structure of the database:

• Logical Design – Deciding on the database schema. Database design


requires that we find a “good” collection of relation schemas.
• Business decision – What attributes should we record in the
database?
• Computer Science decision – What relation schemas should we
have and how should the attributes be distributed among the
various relation schemas?
• Physical Design – Deciding on the physical layout of the database

1.41
History of Database Systems

• 1950s and early 1960s:


• Data processing using magnetic tapes for storage
• Tapes provided only sequential access
• Punched cards for input

• Late 1960s and 1970s:


• Hard disks allowed direct access to data
• Network and hierarchical data models in widespread use
• Ted Codd defines the relational data model
• Would win the ACM Turing Award for this work
• Oracle releases first commercial relational database
• High-performance transaction processing

1.42
History of Database Systems (Cont.)

• 1980s:
• Research relational prototypes evolve into commercial systems
• SQL becomes industrial standard
• Parallel and distributed database systems
• Wisconsin, IBM, Teradata
• Object-oriented database systems
• 1990s:
• Large decision support and data-mining applications
• Data warehouses
• Emergence of Web commerce

1.43
History of Database Systems (Cont.)

• 2000s
• Big data storage systems
• Google BigTable, Yahoo PNuts, Amazon,
• “NoSQL” systems.
• Big data analysis: beyond SQL
• Map reduce
• 2010s
• SQL reloaded
• SQL front end to Map Reduce systems
• Massively parallel database systems
• Multi-core main-memory databases

1.44
Database Engine
• A database system is partitioned into modules that deal with each of
the responsibilities of the overall system.
• The functional components of a database system can be divided into
• The storage manager,
• The query processor component,
• The transaction management component.

1.45
Storage Manager

A program module that provides the interface between


the low-level data stored in the database and the
application programs and queries submitted to the
system.

1.46
Storage Manager (Cont.)

The storage manager implements several data structures as part of the


physical system implementation:

• Data files -- store the database itself.


• Data dictionary -- stores metadata about the structure of the
database, in particular the schema of the database.
• Indices -- can provide fast access to data items. A database index
provides pointers to those data items that hold a particular value.

1.47
Query Processor

• The query processor components include:


• DDL __________ -- interprets DDL statements and records the
definitions in the data dictionary.
• DML __________ -- translates DML statements in a query
language into an evaluation plan consisting of low-level
instructions that the query evaluation engine understands.
• The DML compiler performs query optimization; that is, it picks
the lowest cost evaluation plan from among the various
alternatives.
• Query evaluation engine -- executes low-level instructions
generated by the DML compiler.

1.48
Query Processor

• The query processor components include:


• DDL interpreter -- interprets DDL statements and records the
definitions in the data dictionary.
• DML _________ -- translates DML statements in a query language
into an evaluation plan consisting of low-level instructions that the
query evaluation engine understands.
• The DML compiler performs query optimization; that is, it picks
the lowest cost evaluation plan from among the various
alternatives.
• Query evaluation engine -- executes low-level instructions
generated by the DML compiler.

1.49
Query Processor

• The query processor components include:


• DDL interpreter -- interprets DDL statements and records the
definitions in the data dictionary.
• DML compiler -- translates DML statements in a query language
into an evaluation plan consisting of low-level instructions that the
query evaluation engine understands.
• The DML compiler performs query optimization; that is, it picks
the lowest cost evaluation plan from among the various
alternatives.
• Query evaluation engine -- executes low-level instructions
generated by the DML compiler.

1.50
Transaction Management

• A transaction is a collection of operations that performs a


single logical function in a database application.

• Transaction-management component ensures that the


database remains in a consistent (correct) state despite
system failures (e.g., power failures and operating system
crashes) and transaction failures.

• Concurrency-control manager controls the interaction


among the concurrent transactions, to ensure the
consistency of the database.

1.51
Database Engine
• A database system is partitioned into modules that deal with each of
the responsibilities of the overall system.
• The functional components of a database system can be divided into
• __________________________
• __________________________
• __________________________

1.52
Database Engine
• A database system is partitioned into modules that deal with each of
the responsibilities of the overall system.
• The functional components of a database system can be divided into
• The storage manager,
• ___________________________.
• ___________________________.

1.53
Database Engine
• A database system is partitioned into modules that deal with each of
the responsibilities of the overall system.
• The functional components of a database system can be divided into
• The storage manager,
• The query processor component,
• ___________________________.

1.54
Database Engine
• A database system is partitioned into modules that deal with each of
the responsibilities of the overall system.
• The functional components of a database system can be divided into
• The storage manager,
• The query processor component,
• The transaction management component.

1.55
Database Applications
Database applications are usually partitioned into two or three
parts

• Two-tier architecture -- the application resides at the client


machine, where it invokes database system functionality at the
server machine

1.56
Database Applications
Database applications are usually partitioned into two or three
parts

• Two-tier architecture -- the application resides at the client


machine, where it invokes database system functionality at the
server machine
• Three-tier architecture -- the client machine acts as a front end and
does not contain any direct database calls.
• The client end communicates with an application server, usually
through a forms interface.
• The application server in turn communicates with a database
system to access data.

1.57
Two-tier and three-tier architectures

1.58
Transactions

Requirements for transactions:

• _______________________
• _______________________
• _______________________
• _______________________

1.59
Transactions

ACID is an acronym that stands for:

-Atomicity
-Consistency
-Isolation
-Durability

1.60

You might also like