Databases: Instructor: Engr. Muhammad Umer Haroon

You are on page 1of 42

Databases

Instructor: Engr. Muhammad Umer Haroon


General Course Outline
• Database Management system Concepts:
• Introduction and history
• Conventional file handling versus database.
• Conceptual, Community and user views of data, the interface
between their view
• Data modeling: Hierarchical, network and relational models (we will
study in detail), entities, attributes and relations, Relationship
one-to-one, one-to-N, M to N representations. We will study most
commonly used ERDs rather to explain the above terms.).
Course Outline
• The relational model in detail. An existing relational database as an
example. Construction and manipulation of a relational model, High
level operators, relational algebra, relational calculus
• Query by example approach to using relational database.
• Normalization, the need to normalize and the concept of normal
forms up to BCNF.
Course Outline
• SQL, the query language

Database operational requirements:


• Integrity of data Integrity rules and triggered procedures.
• Security of data, passwords, profiles, statistical databases
problem, recovery from failure, transaction failures and
system failure, two phases commit. Restart facilities.
• and if we are not short of time then we will also study
the following
• Concurrency, locking techniques and time stamping
techniques. Protocols to ease the problem.
• State of the art: Distributed database, database machine.
TEXT AND REFERENCE
BOOKS
Main text book
Modern Database Management, by Jeffrey A.
Hoffer, Mary B. Prescott, Fred R. McFadden (the
newer the better)
Reference books for this course
• “An Introduction to Data Base Systems” By: C. J. Date,
Addison-Wesley Pub.
• “Data Base (A Primer)” By: C. J. Date
• “Fundamental of Database Systems” By: S.M. Deen
• “An End-User’s Guide to Database” By: James Martin.
Week 1 Outline
• Database-System Concepts and Applications
• Purpose of Database Systems
• View of Data
• Database Languages
• Relational Databases
• Database Design
• Data Storage and Querying
• Transaction Management
• Database Users and Administrators
• History of Database Systems
What is a Database

?
Database System Concepts Applications
• Data: Known facts
• Information: Processed data
• Database: Organised Collection of interrelated data
• DBMS contains information about a particular
enterprise
-Set of programs to access and manipulate the data
– An environment that is both convenient and efficient to use
• Database Applications:
– Banking: all transactions
– Airlines: reservations, schedules
– Universities: registration, grades
– Sales: customers, products, purchases
– Online retailers: order tracking, customized recommendations
– Manufacturing: production, inventory, orders, supply chain
– Human resources: employee records, salaries, tax deductions
• Databases touch all aspects of our lives
Purpose of Database Systems
• In the early days, database applications were built
directly on top of file systems
• Drawbacks of using file systems to store data:
– Data redundancy and inconsistency
• Multiple file formats, duplication of information in different
files
– Lengthy development time
• Need to write a new program to carry out each new task
– Data isolation — multiple files and formats
• Data stored in many files. Difficult to run queries
Drawbacks of using file 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
– Program-Data Dependence
– Concurrent access by multiple users
• Concurrent accessed needed for performance
• Uncontrolled concurrent accesses can lead to
inconsistencies
– Example: Two people reading a balance and updating it at the
same time
– Security problems
• Hard to provide user access.
• Database systems offer solutions to all the above
problems
View of Data
• Physical level: describes how a record (e.g.,
customer) is stored.
• Logical level: describes data stored in database,
and the relationships among the data.
type customer = record
customer_id : string;
customer_name : string;
customer_street : string;
customer_city : 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.
Level of Abstraction
An architecture for a database system
Schemas
• Similar to types and variables in programming languages
• Schema – the structure of the database
– Example: The database consists of information about a set
of customers and accounts and the relationship between
them)
– Analogous to type information of a variable in a program

A database schema is the skeleton structure that


represents the logical view of the entire database. It
defines how the data is organized and how the
relations among them are associated. It formulates all
the constraints that are to be applied on the data.
• Physical Database Schema − This schema
pertains to the actual storage of data and its
form of storage like files, indices, etc. It defines
how the data will be stored in a secondary
storage.
• Logical Database Schema − This schema
defines all the logical constraints that need to be
applied on the data stored. It defines tables,
views, and integrity constraints.
Database schema is the skeleton of database. It is
designed when the database doesn't exist at all.
A database schema does not contain any data or
information.
Instance
• A database instance is a state of operational
database with data at any given time. It contains
a snapshot of the database. Database instances
tend to change with time.

• Instance – the actual content of the database at a


particular point in time
– Analogous to the value of a variable
Physical Data Independence – the ability to modify
the physical schema without changing the logical schema

– Applications depend on the logical schema


Data Models
• A collection of tools for describing
– Data
– Data relationships
– Data semantics
– Data constraints
• Relational model
• Entity-Relationship data model (mainly for database
design)
• Object-based data models (Object-oriented and
Object-relational)
• Semi structured data model (XML)
• Other older models:
– Network model
– Hierarchical model
Database Language
Data Manipulation Language (DML)
• Language for accessing and manipulating the data
organized by the appropriate data model
– DML also known as query language
• INSERT, UPDATE, DELETE,SELECT

• SQL is the most widely used query language


Database Language
Data Definition Language (DDL)
• Specification notation for defining the database
schema
Example: create table account (
account-number char(10),
balance integer)
• DDL compiler generates a set of tables stored in a
data dictionary
Data Dictionary
• Data dictionary contains metadata (i.e., data
about data)
– Database schema
– Data storage and definition language
• Specifies the storage structure and access methods used
– Integrity constraints
• Domain constraints
• Referential integrity (references constraint in SQL)
• Assertions
– Authorization
Relational Databases
Relational Model
• Example of tabular data in the relational model

Attributes
A Sample Relational Database
SQL
• SQL: widely used non-procedural language
– Example: Find the name of the customer with customer-id
192-83-7465
select customer.customer_name
from customer
where customer.customer_id = ‘192-83-7465’

• Application programs generally access databases


through one of
– Language extensions to allow embedded SQL
– Application program interface (e.g., ODBC/JDBC) which allow SQL
queries to be sent to a database
Database Design
The process of designing the general structure of the
database:
• Conceptual and 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 (Operating system, hardware)
The Entity-Relationship Model
• Models an enterprise as a collection of entities and
relationships
– Entity: a “thing” or “object” in the enterprise that is
distinguishable from other objects
• Described by a set of attributes
– Relationship: an association among several entities
• Represented diagrammatically by an
entity-relationship diagram:
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.
Data Mining and Analysis
• The process of semi-automatically analyzing large
databases to find useful patterns and rules
• Similar to Knowledge Discovery in AI (also called
Machine Learning), but dealing with very large
database
• Decision Support System for Business
– Data-Warehouse (DW)
– On-Line Analytical Processsing (OLAP)

• Information Retrieval from unstructured textual data


Database Architecture

The architecture of a database systems is greatly


influenced by
the underlying computer system on which the
database is running:
• Centralized
• Client-server
• Parallel (multi-processor)
• Distributed

DETAILS IN UPCOMING LECTURES


Database architecture
Database Users and Administrators
Database Users
Users are differentiated by the way they expect to
interact with the system
• Application programmers – interact with system
through DML calls
• Naïve users – invoke one of the permanent
application programs that have been written
previously
– Examples, people accessing database over the
web, bank tellers, clerical staff
Database Administrator
• Coordinates all the activities of the database system;
the database administrator has a good
understanding of the enterprise’s information
resources and needs.
• Database administrator's duties include:
– Schema definition
– Storage structure and access method definition
– Granting user authority to access the database
– Specifying integrity constraints
– Acting as liaison[connection] with users
– Monitoring performance and responding to changes in
requirements
History of Database Systems
• 1950s and early 1960s:
– Data processing using magnetic tapes for storage
• Tapes provide only sequential access
– Punched cards for input
• Late 1960s and 1970s:
– Hard disks allow 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
• IBM Research begins System R prototype
• UC Berkeley begins Ingres prototype
– High-performance (for the era) transaction processing
• 1980s: History (cont.)
– Research relational prototypes evolve into
commercial systems
• SQL becomes industrial standard
– Parallel and distributed database systems
– Object-oriented database systems
• 1990s:
– Large decision support and data-mining
applications
– Large multi-terabyte data warehouses
– Emergence of Web commerce
History (cont.)
• 2000s:
– XML and XQuery standards
– Automated database administration
– Object Oriented and Object Based
– Multimedia databases etc
Summary
• A database-management system(DBMS) consists of
a collection of interrelated data and a collection of
programs to access that data. The data describe one
particular enterprise.
• The primary goal of a DBMS is to provide
environment that is both convenient and efficient for
people to use in retrieving and storing information.
• Database systems are ubiquitous today, and most
people interact, either directly or indirectly, with
databases many times every day.
Summary
• Database systems are designed to store large bodies of
information. The management of data involves both the
definition of structures for the storage of information and
provision of mechanisms for the manipulation of
information.
In addition, the database system must provide for the
safety of the information stored, in the face of system
crashes or attempts at unauthorized access.
If data are to be shared among several users, the
system must avoid possible anomalous results.
Summary
• A major purpose of a database system is to provide users
with an abstract view of the data.
That is, the system hides certain details of how the data are
stored and maintained.
• Underlying the structure of a database is the data model: a
collection of conceptual tools for describing data, data
relationships, data semantics, and data constraints.
• A data-manipulation language (DML) is a language that
enables users to access or manipulate data
• The overall design of the database is called the database
schema. A database schema is specified by a set of
definitions that are expressed using data definition language
(DDL).
Summary
• The relational data model is widely used to store
data in databases. Other data models are the
object-oriented model, the object-relational model,
and semi-structured data models..

• The entity-relationship (E-R) data model is a widely


used data model, and it provides a convenient
graphical representation to view data, relationships
and constraints.
Summary
• Database applications are typically broken up into
front-end part that runs at client machines and a
part that runs at the back-end.
In two-tier architectures, the front-end directly
communicates with a database running at the
back-end.
In three -tier architectures, the back end part is
itself broken up into an application server and a
database server.
Summary
• Database users can be categorized into several
classes, and each class of users usually uses
different type of interface to the database.

You might also like