You are on page 1of 11

What is Database?

 A database is an organized collection of structured


18CSC303J – DATABASE information, or data, typically stored electronically in a
computer system.
MANAGEMENT SYSTEM  A database is usually controlled by a Database
Management System(DBMS).
 Together, the data and the DBMS, along with the
UNIT 1 applications that are associated with them, are
referred to as a database system, often shortened to
just database.
 Examples: Telephone directory, students database in an
institution, etc.
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

What is Database Management


System? File Processing System
3 4

 File Processing System (FPS) is a way of storing,


 Database Management Systems (DBMS) are retrieving and manipulating data which is present in
software systems used to store, retrieve, and run various files.
queries on data.  Files are used to store various documents.
 A DBMS serves as an interface between an end-user  A File Management system is a DBMS that allo ws
and a database, which allo ws users to create and access to single files or tables at a time. In a File
manipulate(read, update, and delete) data in the System, data is directly stored in set of files. It
database. contains flat files that have no relation to other files
 Examples : MYSQL, ORACLE, MS SQL SERVER, (when only one table is stored in single file, then this
AMAZON RDS, etc. file is known as flat file).

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Advantages of DBMS over FPS Advantages of DBMS over FPS


5 6

 Data redundancy and inconsistency  Integrity problems


 Data is stored in multiple file formats resulting  Data stored in the database must satisfy certain types of
consistency constraints.
induplication of information in different files
 But in file system, it is difficult to add the constraints in the
 Difficulty in accessing data programs to enforce the changes.
 Need to write a new program to carry out eac h  The problem is compounded when constraints involve several
data items from different files.
new task
 Atomicity problems
 Data isolation  Failures may leave database in an inconsistent state with
 Since data are scattered in different file formats, partial updates carried out
writing new application programs to retrieve the  Example: Transfer of funds from one account to another
appropriate data is difficult. should either complete or not happen at all

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

1
Advantages of DBMS over FPS Introduction to DBMS
7 8

 Concurrent access anomalies  A database-management system (DBMS) is a


 Concurrent access needed for performance collection of interrelated data and a set of
 Uncontrolled concurrent accesses can lead to programs to access those data.
inconsistencies  The collection of data, usually referred to as the
 Ex: Two people reading a balance (say 100) and updating database, contains information rele vant to an
it by withdrawing money (say 50 each) at the same time
enterprise.
 Security problems  The prim ary goal of a DBMS is to provide a way to
 Hard to provide user access to some, but not all, store and retrieve database informatio n that is both
data convenient and efficient.

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Cont.. Applications of DBMS


9 10
 Database systems are used to manage collections  Enterprise Information
of data that are:  Sales: customers, products, purchases
 Highly valuable  Accounting: payments, receipts, assets
Relatively large
  Human Resources: Information about employees,
 Accessed by multiple users and applications, often salaries, payroll taxes.
at the same time.  Manufacturing: management of production,
 A modern database system is a complex software inventory, orders, supply chain.
system whose task is to manage a large, complex  Telecommunication: records of calls, texts, and data
collection of data. usage, generating monthly bills, maintaining
 Databases touch all aspects of our lives balances on prepaid calling cards
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Applications of DBMS Applications of DBMS


11 12

 Banking and finance  Universities: registration, grades


 customer information, accounts, loans, and banking  Airlines: reservations, schedules
transactionsCredit card transactions  Document databases
 Finance: sale s and purchases of financial
 Web-based services
instruments (e.g., stocks and bonds; storing real-
 Online retailers: order tracking, customized
time market data
recommendations
 Navigation systems:  Online advertisements
 For maintaining the locations of varies places of interest
along with the exact routes of roads, train systems,
buses, etc.
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

2
Purpose of Database System Purpose of Database System
13 14

 Since informatio n is so im portant in  Database systems offer solutions to all the


most organizatio ns, computer scientists have problems given below:
develo ped a large body of concepts and  Data redundancy and inconsistency
techniques for managing data which is known as  Difficulty in accessing data
database.  Data isolation
 Integrity problems
 Atomicity problems
 Concurrent access anomalies
 Security problems

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Views of Data Views of Data


15 16

 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,
data semantics, 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

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Levels of Abstraction Cont..


17 18

 Physical level  The logical level thus describes the entire database in
 The lowest level of abstraction describes how the data terms of a small number of relatively simple structures.
are actually stored. The physical level describes Although implementation of the simple structures at the
complex low-level data structures in detail logical level may involve complex physical-level
structures, the user of the logical level does not need to
 Logical level be aware of this complexity.
 The next-higher level of abstraction describes what  This is referred to as physical data independence.
data are stored in the database, and what Database administrators, who must decide what
relationships exist among those data. information to keep in the database, use the logical
level of abstraction.

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

3
Cont.. Database System Architecture
19 20

 View level  The architecture of a database system is greatly


 The highest level of abstraction describes only part of influenced by the underly ing computer system on
the entire database.
 Even though the logical level uses simpler structures,
which the database system runs.
complexity remains because of the variety of  Database systems can be centralized, or client-
information stored in a large database.
 Many users of the database system do not need all this
server, where one server machine executes work on
information; instead, they need to access only a part of behalf of multiple client machines.
the database.
 The view level of abstraction exists to simplify their
interaction with the system. The system may provide
many views for the same database

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Cont..
21

 Centralized databases
 One to a few cores, shared memory
 Client-server
 One server machine executes work on behalf of multiple client machines.
 Parallel databases
 Many core shared memory
 Shared disk
 Shared nothing
 Distributed databases
 Geographical distribution
 Schema/data heterogeneity
Prepared by S.S.KIRUTHIKA, AP/CSE
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM 22 SRM IST,RAMAPURAM

Storage Manager Storage Manager


23 24
 A program module that provides the interface between  The storage manager implements several data
the low-level data stored in the database and the structures as part of the physical system
application programs and queries submitted to the implementation:
system.  Data files -- store the database itself
 The storage manager is responsible to the following tasks:  Data dictionary -- s tores metadata about the structure of
 Interaction with the OS file manager the database, in particular the schema of the database.
 Efficient storing, retrieving and updating of data
 Indices -- can provide fast access to da ta items. A
 The storage manager components include: database index provides pointers to those data i tems that
 Authorization and integrity manager hold a particular value.
 Transaction manager
 File manager
 Buffer manager
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

4
Query Processor Query Processing
25 26

 The query processor components include:  Parsing and Translation


 DDL interpreter -- interprets DDL s tatements and records  Optimization
the definitions in the data dictionary.  Evaluation
 DML compiler -- translates DM L s tatements 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.

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Transaction Management Cont..


27 28

 A transaction is a collection o f operations that  Database applications are usually partitioned into
performs a single logical function in a database two or three parts
application  Two-tier architecture
 Transact ion-m anagement component ensures that  Three- tier architecture
the dat abase 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 conc urrent transactions, to ensure the
consistency of the database.
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Database System Architecture Two-Tier Architecture


29 30

 In a two-tier architecture, the application resides at


the clie nt machine, where it invokes database
system functio nality at the server machine through
query language statements.
 Application program interface standards like ODBC
and JDBC are used for interactio n between the
client and the server

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

5
Three-Tier Architecture Data Independence
31 32

 In a three-tier architecture, the client machine acts  Data independence can be explained using the
as merely a front end and does not contain any three-schema architecture.
direct database calls.  Data independence refers characteristic of being
 Instead, the client end communicates with an able to modify the schema at one level of the
application server, usually through a forms database system without altering the schema at the
interface. next higher level.
 The application server in turn communicates with a  There are two types of data independence:
database system to access data.  Physical data independence
 Logical data independence

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Data Independence Physical Data Independence


33 34

 Physical data independence can be defined as the


capacity to change the internal schema without
having to change the conceptual schema.
 If we do any changes in the storage size of the
database system server, then the Conceptual
structure of the database will not be affected.
 Physical data independence is used to separate
conceptual levels from the internal levels.
 Physical data independence occurs at the logical
interface level.

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Logical Data Independence Data Models


35 36

 Logical data independence refers characteristic of  Data Models are fundamental entities to introduce
being able to change the conceptual schema abstraction in a DBMS.
without having to change the external schema.
 Data Model is a collection of tools for describing
 Logical data independence is used to separate the
 Data
external level from the conceptual view.
 Data relationships
 If we do any changes in the conceptual view of the  Data semantics
data, then the user view of the data would not be  Data constraints
affected.
 Logical data independence occurs at the user
interface level.

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

6
Data Abstraction Levels of Data Abstraction
37 38

 Database systems comprise complex data structures.


 In order to make the system efficient in terms o f
retrieval of dat a, and reduce complexity in terms of
usability of users, developers use abstraction i.e.
hide irrelevant details from the users.
 This approach simplifies database design.
 There are three levels of absraction.
 Physical Level
 Logical Level
 View Level
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Levels of Abstraction Cont..


39 40

 Physical level  The logical level thus describes the entire database in
 The lowest level of abstraction describes how the data terms of a small number of relatively simple structures.
are actually stored. The physical level describes Although implementation of the simple structures at the
complex low-level data structures in detail logical level may involve complex physical-level
structures, the user of the logical level does not need to
 Logical level be aware of this complexity.
 The next-higher level of abstraction describes what  This is referred to as physical data independence.
data are stored in the database, and what Database administrators, who must decide what
relationships exist among those data. information to keep in the database, use the logical
level of abstraction.

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Cont.. Data Abstraction – Schema, Instance


41 42

 View level  Logical Schema – the overall logical structure of the


 The highest level of abstraction describes only part of database
the entire database.  Example: The database consists of information about a set
 Even though the logical level uses simpler structures, of customers and accounts in a bank and the relationship
complexity remains because of the variety of between them
information stored in a large database.
 Analogous to type information of a variable in a program
 Many users of the database system do not need all this
information; instead, they need to access only a part of  Physical schema – the overall physical structure of the
the database. database
 The view level of abstraction exists to simplify their
interaction with the system. The system may provide  Instance – the actual content of the database at a
many views for the same database particular point in time
 Analogous to the value of a variable
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

7
Cont.. Relational Model
43 44

 The data models can be classified into four different  The relational model uses a collectio n of tables to
categories: represent both data and the relationships among
 Relational model those data.
 Entity-Relationship data model (mainly for database design)
 Each table has multiple columns, and each column
 Object-based data models (Object-oriented and Object-
relational)
has a unique name. Table s are also known as
relations.
 Semi-structured data model (XML)
 Other older models:  The relational model is an example of a record-
 Network model based model
 Hierarchical model

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Entity-Relationship Model Object-based Data Model


45 46

 . The entity-relationship (E-R) data model uses a  object-orie nted data model that can be seen as
collectio n of basic objects, calle d entities, and extending the E-R model with notions of
relationships among these objects. encapsulation, methods (functions), and object
 An entity is a “thing” or “object” in the real world identity.
that is distinguishable from other objects.  The obje ct-relational data model combines features
of the obje ct-oriented data model and relational
data model.

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Semi-structured Data Model Other Data Models


47 48

 The semi-structured data model permits the  Network data model and the hierarchical data
specification of data where individual data items of model preceded the relational data model.
the same type may have different sets of attributes.  These models were tied closely to the underlying
 The Extensible Markup Language (XML) is widely implementatio n, and complicated the task of
used to represent semi-structured data. modeling data.
 As a result they are used little now, except in old
database code that is still in service in some places.

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

8
Evolution of Data Models Evolution of Data Models
49 50
 1950s and early 1960s:  1980s:
 Data processing using magnetic tapes for storage  Research relational prototypes evolve into commercial systems

 Tapes provided only sequential access  SQL becomes industrial standard

 Punched cards for input  Parallel and distributed database systems

 Late 1960s and 1970s:  Wisconsin, IBM, Teradata

 Hard disks allowed direct access to data  Object-oriented database systems

 Network and hierarchical data models in widespread use  1990s:


 Ted Codd defines the relational data model  Large decision support and data-mining applications

 Would win the ACM Turing Award for this work  Large multi-terabyte data warehouses
 IBM Research begins System R prototype  Emergence of Web commerce

 UC Berkeley (Michael Stonebraker) begins Ingres prototype


 Oracle releases first commercial relational database

 High-performance (for the era) transaction processing

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Database Users
Database Users
51

 There are four different types of databasse users.


 Naive Users
 Application Programmers
 Sophisticated users
 Database administrators(DBA)

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM 52 Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Cont.. Cont..
53 54

 Naive Users  Sophisticated Users


 The native users need not be aware of the presence of
 They are those users who interact with the system
the database system.
without writing the program instead they form their
 They are end users of the database who works through request in database query language.
a menu driven application programs, where the type
 They are the SQL programmers, who are going to deal
and range of response is always indicated to the user
directly with the database. They write queries to delete
 Application Programmer or select or insert and update the database.
 The application programmer users who are responsible
for developing the application programs or user
interface. The application programs could be written in
high level language. For example − Java, .net, php etc ,
Prepared by S.S.KIRUTHIKA, AP/CSE
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM SRM IST,RAMAPURAM

9
Role of DBA Database Languages
55 56

 A person who has central control over the system is called a  A DBMS has appropriate languages and interfaces
database administrator (DBA). Functions of a DBA include: to express database queries and updates.
 Schema definition
 Storage structure and access-method definition  Database languages can be used to read, store
 Schema and physical-organization modification and update the data in the database.
 Granting of authorization for data access  The types of database languages are:
 Routine maintenance
 DDL – Data Definition Language
 Periodically backing up the database
 Ensuring that enough free disk space is available for normal operations,  DML – Data Manipulation Language
and upgrading disk space as required  DCL – Data Control Language
 Monitoring jobs running on the database
 TCL – Transaction Control Language

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Data Definition Language(DDL) DDL Commands


57 58

 Data Definitio n Language is used to define  Create: It is used to create objects in the database.
database structure or pattern.  Alter: It is used to alter the structure of the
 It is used to create schema, tables, indexes, database.
constraints, etc. in the database.  Drop: It is used to dele te obje cts from the
 Using the DDL statements, you can create the database.
skeleton of the database.  Truncate: It is used to remove all records from a
 Data definitio n language is used to store the table.
informatio n of metadata like the number of table s  Rename: It is used to rename an object.
and schemas, their names, indexes, columns in each  Comment: It is used to comment on the data
table, constraints, etc. dictionary.
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

Data Manipulation Language(DML) Data Control Language(DCL)


59 60

 It is used for accessing and manipulating data in a  Data Control Language is used to retrie ve the
database. It handles user requests. stored or saved data.
 The basic DML commands are:  The DCL execution is transactional. It also has
 Select: It is used to retrieve data from a database. rollback parameters.
 Insert: It is used to insert data into a table.  DCL commands are:
 Update: It is used to update existing data within a  Grant: It is used to give user access privileges to a
table. database.
 Delete: It is used to delete all records from a table.  Revoke: It is used to take back permis sio ns from the
user.
Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

10
Transaction Control Language(TCL)
61

 TCL is used to run the changes made by the DML


statement. TCL can be grouped into a logical
transaction.
 TCL commands are:
 Commit: It is used to save the transaction on the
database.
 Rollback: It is used to restore the database to
original since the last Commit.

Prepared by S.S.KIRUTHIKA, AP/CSE SRM IST,RAMAPURAM

11

You might also like