Week 1&2 (Introduction To DBMS)
Week 1&2 (Introduction To DBMS)
Introduction to DBMS
1.1
DEPARTMENT: COMPUTER SCIENCE AND ENGINEERING
1.2
COURSE OUTCOMES
1.3
TOPICS To Be COVERED
1.4
TOPICS To Be COVERED contd..
1.5
TEXT BOOKS, AND/OR REFERENCE
MATERIAL
Korth, Silbertz, Sudarshan, “Database Concepts”, McGraw Hill
Elmasri, Navathe, “Fundamentals Of Database Systems”, Addision
Wesley
Date C J, “An Introduction To Database System”, Addision Wesley
Bipin C. Desai, “An introduction to Database Systems”, Galgotia
Publication
Rob and Coronel, “Database Systems 5thEdition”,Cengage Learning,
New Delhi
1.6
Outline
1.7
Database Management System (DBMS)
1.8
University Database Example
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
In the early days, database applications were built directly on
top of file systems
1.9
Drawbacks of using file systems to store data
1.10
Drawbacks of using file systems to store data (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
Example: 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
1.11
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.12
View of Data
1.13
View of Data- Three Level Architecture
1.15
Mapping and Data Independence
Mapping: The process to convert a request from external
level and data stored is called mapping. The mapping
defines the correspondence between three levels.
External/Conceptual Mapping
Conceptual/Internal Mapping
Mapping and Data Independence
Data Independence: The ability to modify a scheme
definition in one level without affecting a scheme definition in a
higher level is called data independence.
Physical Data Independence – the ability to modify the
physical schema without changing the logical 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.
Logical data Independence- The ability to change logical
schema without changing external schema is called logical data
independence. E.g by adding or removing attributes , tables etc.
Architecture of DBMS
1.18
Internal Schema
Lowest level of Abstraction and has knowledge of both h/w and s/w.
Defines how data physically stored in database.
Also called Physical Schema
Location
Name
Format
1.19
Conceptual Schema
It deals with the modeling of whole database.
Don’t know how and where the data is stored but knows “WHAT
DATA IS STORED”.
The users of this level are not concerned with how these logical data
structures will be implemented at the physical level, rather they just
are concerned about what information is to be kept in the database.
Example When we use the Describe Command.
1.20
External Schema
It is very close to users and is the highest level of Abstraction.
Allows to see only the data of interest to them.
Users – Application programmers or end-users.
Any no. of external views – external schema.
1.21
Types of Database Models
A Database model defines the logical design and structure of a database
and defines how data will be stored, accessed and updated in a database
management system
A collection of tools for describing
Data
Data relationships
Data semantics
Data constraints
1.22
Hierarchical Model
1.23
Hierarchical Model
1.24
Network Model
This is an extension of the Hierarchical model. In this model data is
organized more like a graph, and are allowed to have more than one
parent node.
In this database model data is more related as more relationships are
established in this database model. Also, as the data is more related,
hence accessing the data is also easier and fast. This database model
was used to map many-to-many data relationships.
1.25
Network Model
1.26
Entity-Relationship Model
In this database model, relationships are created by dividing object of
interest into entity and its characteristics into attributes.
Different entities are related using relationships.
E-R Models are defined to represent the relationships into pictorial
form to make it easier for different stakeholders to understand.
This model is good to design a database, which can then be turned
into tables in relational model.
1.27
Entity-Relationship Model
1.28
Relational Model
In this model, data is organized in two-dimensional tables and the
relationship is maintained by storing a common field.
The basic structure of data in the relational model is tables. All the
information related to a particular type is stored in rows of that table.
Hence, tables are also known as relations in relational model.
1.29
Relational Model
1.30
Object-Relational Data Models
Relational model: flat, “atomic” values
Object Relational Data Models
Extend the relational data model by including object orientation and
constructs to deal with added data types.
Allow attributes of tuples to have complex types, including non-atomic
values such as nested relations.
Preserve relational foundations, in particular the declarative access to
data, while extending modeling power.
Provide upward compatibility with existing relational languages.
1.31
Semistructured Data Model
Permits the specification of data where individual data items of the
same type have different set of attributes.
XML(Extensible Mark up Language) is used to represent semi
structured data.
1.32
RDBMS
A Relational Database Management System is the DBMS that is
based on the relational model.
It stores the data in the form of related tables. A table is a collection of
related data entries and it consists of columns and rows.
RDBMS is the basis for SQL, and for all modern database systems
such as:MS SQL Server, IBM DB2, Oracle, MySQL, Microsoft Access.
1.33
SQL
SQL stands for Structured Query Language.
It is used to access and manipulate database.
What Can SQL do?
SQL can execute queries against a database
SQL can retrieve data from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new databases
SQL can create new tables in a database
1.34
1.35
DDL
DDL is the Data Definition Language, which deals with database
schemas and descriptions, of how the data should reside in the
database.
CREATE - to create a database and its objects like (table, index,
views, store procedure, function, and triggers)
ALTER - alters the structure of the existing database
DROP - delete objects from the database
TRUNCATE - remove all records from a table, including all spaces
allocated for the records are removed
COMMENT - add comments to the data dictionary
RENAME - rename an object
1.36
DML
DML is the Data Manipulation Language which deals with data
manipulation and includes most common SQL statements such
SELECT, INSERT, UPDATE, DELETE, etc., and it is used to store,
modify, retrieve, delete and update data in a database.
SELECT - retrieve data from a database
INSERT - insert data into a table
UPDATE - updates existing data within a table
DELETE - Delete all records from a database table
CALL - call a PL/SQL or Java subprogram
1.37
DCL
DCL is the Data Control Language which includes commands such as
GRANT and mostly concerned with rights, permissions and other
controls of the database system.
GRANT - allow users access privileges to the database
REVOKE - withdraw users access privileges given by using the
GRANT command.
1.38
TCL
TCL is the Transaction Control Language which deals with a
transaction within a database.
COMMIT - commits a Transaction
ROLLBACK - rollback a transaction in case of any error occurs.
Restores database to original state since the last COMMIT command
in transactions
SAVEPOINT - to rollback the transaction making points within groups.
SET TRANSACTION - specify characteristics of the transaction
1.39
Database Access from Application Program
SQL does not support actions such as input from users, output to
displays, or communication over the network.
Such computations and actions must be written in a host language, such
as C/C++, Java or Python, with embedded SQL queries that access the
data in the database.
Application programs -- are programs that are used to interact with the
database in this fashion.
1.40
Database Design
1.41
Overall Database Structure
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.42
Database Architecture
(Centralized/Shared-Memory)
1.43
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.
The storage manager is responsible to the following tasks:
Interaction with the OS file manager
Efficient storing, retrieving and updating of data
The storage manager components include:
Authorization and integrity manager: Tests for satisfaction of integrity
constraints and checks the authority of users to access data
Transaction manager: Ensures that database remains in a consistent
state despite system failures and concurrent transaction processing
File manager: Allocation of space on disk storage and data structures
used to represent information stored on disk
Buffer manager: Responsible for fetching data from disk storage into
main memory.
1.44
Storage Manager (Cont.)
1.45
Query Processor
1.46
Query Processing
1.47
Query Processing (Cont.)
Alternative ways of evaluating a given query
Equivalent expressions
Different algorithms for each operation
Cost difference between a good and a bad way of evaluating a
query can be enormous
Need to estimate the cost of operations
Depends critically on statistical information about relations
which the database must maintain
Need to estimate statistics for intermediate results to compute
cost of complex expressions
1.48
Database Applications
1.49
Two-tier and three-tier architectures
1.50
Database Users and Administrators
Database
1.51
Database Users
Naïve Users: are unsophisticated users who interact with the system
by invoking one of the application programs that have been written
previously
1.52
Database Administrator
A person who has central control over the system is called a database
administrator (DBA). Functions of a DBA include:
Schema definition
Storage structure and access-method definition
Schema and physical-organization modification
Granting of authorization for data access
Routine maintenance
Periodically backing up the database
Ensuring that enough free disk space is available for normal
operations, and upgrading disk space as required
Monitoring jobs running on the database
1.53
History of Database Systems
1.54
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
Large multi-terabyte data warehouses
Emergence of Web commerce
1.55
History of Database Systems (Cont.)
2000s
Big data storage systems
Google BigTable, Yahoo PNuts, Amazon,
“NoSQL” systems.
2010s
SQL reloaded
SQL front end to Map Reduce systems
1.56
End of Week 1&2
1.57