chapter1-Introduction to DBMS
Transcript of chapter1-Introduction to DBMS
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 1/37
CCourseourse 11
IIntroduction tontroduction to DDBMSBMS
Dr. Mohsen Rouached
CComputeromputer SScience (CScience (CS 420420))
DDatabaseatabase MManagement anagement SSystemsystems (DBMS)(DBMS)
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 2/37
Table of contents Definition of DBMS Objective of DBMS
Database System Applications Purpose of Databases
Limitation of the file system based databases
View of Data in Databases
Data Models Database Languages Database Users and Administrator
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 3/37
Definition of DBMS A database management system (DBMS) is
a collection of interrelated data (database)and
a set of programs to access those data.
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 4/37
Objective of DBMS Provide a way for efficient data management
storage and retrieval of the information
Manage large bodies of information Defining structures for the storage of information
Providing the mechanisms for the manipulation of theinformation
Ensure the safety of the information stored Avoid abnormal results when sharing the DB
among several users
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 5/37
Database System Applications Banking: all transactions
Airlines: reservations, schedules
Universities: registration, grades, student information Sales: customers, products, purchases
Manufacturing: production, inventory, orders, supplychain
Human resources: employee records, salaries, taxdeductions
Telecommunications: keeping record of calls made,generating monthly bills
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 6/37
Purpose of Database Systems
Limitations of File Systems (1/3)
In the early days, database applications were built on topof file systems Data is stored in separate files Data is manipulated by a set of application programs
As time goes by, the number of files and applicationprograms increases increasing complexity of database application management
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 7/37
Purpose of Database Systems
Limitations of File Systems (2/3)
Drawbacks of using file systems to store data Data redundancy and inconsistency
Redundancy: duplication of information in different files Inconsistency: the various copies of the same data may be different
Difficulty in accessing data Need to write a new program to carry out each new task
Data isolation multiple files and formats Because data are scattered in various files, and files may be in different
formats, writing the appropriate information to retrieve the appropriate data isdifficult
Integrity problems Data values stored in the database must satisfy certain types of consistency
constraints Integrity constraints (e.g. account balance > 0) become part of program code Those constraints are forced by the database system developer Hard to add new constraints or change existing ones
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 8/37
Purpose of Database Systems
Limitations of File Systems (3/3)
Drawbacks of using file systems to store data Atomicity of updates
Failures may leave database in an inconsistent state with partialupdates carried out
E.g. transfer of funds from one account to another should eithercomplete or not happen at all
Concurrent access by multiple users Concurrent accessed needed for performance Uncontrolled concurrent accesses can lead to inconsistencies
E.g. two people reading a balance and updating it at the same time Security problems
Not every user of the database should be able to access all the data
Database systems offer solutions to all previous problems
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 9/37
View of Data in a Database
Recall that
a database management system (DBMS) is a collectionof interrelated data and a set of programs to access andmodify those data.
A major purpose of a database system is to provide userswith an abstract view of data
The system hides certain details of how the data arestored and maintained
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 10/37
View of Data in a Database
The Need for Data Abstraction
The objective of data abstraction is to
simplify the interaction with the databasefrom the user perspective
Most of database users are not computertrained
However, more complexity from the designperspective
Complex data structure to represent data
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 11/37
View of Data in a Database
Data Abstraction Levels
Physical Level: describes how the data is
actually stored Describes low level data structures
Logical Level: describes what data arestored in the database and what
relationships exist between data View Level: describes only part of the
entire database
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 12/37
View of Data in a Database
Data Abstraction Levels
Physical Level: describes how the data is actually stored Describes low level data
structures Logical Level: describes what
data are stored in thedatabase and whatrelationships exist betweendata
View Level: describes onlypart of the entire databaseH
ow to store
What to store
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 13/37
View of Data in a Database
Analogy with data types in programming
Consider high level programming
Physical Level: block of consecutivestorage locations (e.g. bytes) The compiler hides this level of details
from programmers
Logical Level: each record is describedby a type definition Programmers work at this level of
abstraction
Similar to database administrator
View Level: computer users only see aset of applications without details ondata types Similar to users of database
e.g. some database users are notallowed to see the salary of workers for security reasons.
type customer = recordname : string;street : string;
city : integer;end;
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 14/37
Data Models
Definition
The Data Model: a collection of conceptual
tools for describing Data
Data relationship
Data semantics
Consistency constraints A data model provide a way to describe the
design of a database at the physical, logical
and view level
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 15/37
Data Models
Definition
Data models can be classified in four
categories1. Relational model
2. The Entity-Relation model
3. Object-based Data model
4. Semi Structured Data model
Other models: network model,hierarchical model
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 16/37
Data Models
The Relational Model
The Relational Model: uses a collection of tables
to represent both data and the relationship amongthose data.
Each table has multiple column and each column has a
unique name (Attribute)
The most widely used as a data model for databases Vast majority of current database systems are based on
the relational model
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 17/37
Data Models
The Relational ModelSample of a Relational databaseSample of a Relational database
Attributes
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 18/37
Data Models
The Entity-Relationship Model
The Entity-Relationship (E-R) Model: it is based on the
perception of a real world that consists of a collection
basic objects called entities and of relationships among
those objects.
An entity is a ³thing´ or ³object´ from the real world that is
distinguishable from other objects
e.g. c ustomers, acc ounts, bank branc h
A relationship is an association among several entities
e.g. the acc ount Ac1234 is held by the c ustomer Mr. Abdullah
This model is also widely used in database design
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 19/37
Data Models
The Entity-Relationship Model
The Entity-Relationship (E-R) Model: it is basedon the perception of a real world that consists of acollection basic objects called entities and of relationships among those
Rectangles: represent the set of entities
Ellipses: represent the attributes of anentity Diamonds: represent the set of relationships among a member from eachof several entity sets Lines: link the attributes to entity setsand entity sets to relationships
entity
Relationship
entity
Attributes
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 20/37
Data Language
Definition
A database system provides a data definition language to specify the
database schema a data manipulation language to express
database queries and update
In practice, both languages are not separate e.g. SQL (Structured Query Language)
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 21/37
Data Definition Language (DDL) Data Definition Language: specifies the notation for defining the
database schema
e.g.
create table acc ount (acc ount-number char (10),balanc e integer
)
DDL compiler generates a set of tables stored in a d ata d ictionary
Data dictionary contains metadata (i.e., data about data)
The schema of a table is an example of metadata Data storage and definition language
Usually an extension of the data definition language
Language in which the storage structure and access methods used by thedatabase system are specified
Hidden from the user of the database
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 22/37
Data Manipulation Language (DML)
Language for accessing and manipulating the
data organized by the appropriate data model
DML also known as query language
Data manipulation is:
The retrieval of information stored in the database
The insertion of new information into the database
The deletion of the information from the database
The modification (update) of the information from the
database
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 23/37
Data Manipulation Language (DML) Two classes of languages
Procedural ± user specifies what data is required and how to get
those data
Declarative (Nonprocedural) ± user specifies what data is
required without specifying how to get those data (e.g. SQL)
Easy to learn and to use
The database system has to figure out an efficient means of
accessing the data
SQL is the most widely used query language
A Query is a statement requesting the retrieval of the
information
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 24/37
SQL: Some Examples SQL: widely used non-procedural language
e.g. find the name of the customer with customer-id 192-83-7465select custom er.custom er-nam e
from custom erwhere custom er.custom er-id = 192-83-7465
e.g. find the balances of all accounts held by the customer withcustomer-id 192-83-7465
select a ccount .bala nc efrom depositor , a ccount
where d epositor .custom er-id = 192- 83- 7465 andd epositor .a ccount-num ber = a ccount .a ccount-num ber
Application programs generally access databases through one of
Language extensions to allow embedded SQL
Application Program Interface (API) (e.g. ODBC/JDBC) which allow SQL
queries to be sent to a database
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 25/37
Database Users People who work with a database can be
categorized as
database users or database administrators
Users are differentiated by the way they expect to interact with the system
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 26/37
Database Users Four types of database users
Naïve users: invoke one of the permanent application programs that have beenwritten previously
E.g. Bank cashier, people accessing a database over the web
The typical user interface for naïve user is a form interface where the user just fill in theappropriate fields of the form
Application programmers: computer professional that write applicationprograms
Choose a tool from many tools to build a user interface to the database
Interact with the system through DML calls
Sophisticated users: Interact with the system without writing programs Form their requests using a database query language (e.g. Analysts)
Specialized users: write specialized database applications that do not fit intothe traditional data processing framework
E.g. computer-aided design systems, expert systems, environement modeling systems
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 27/37
Database Administrators The Database Administrator (DBA) Coordinates all the activities of the
database system
The DBA has a good understanding of the enterprises information
resources and needs The DBA has central control over the system
Database administrator's duties include:
Schema definition, specifying integrity constraints
Storage structure and access method definition
Schema and physical organization modification
Granting user authority to access the database
Acting as liaison with users
Monitoring performance and responding to changes in requirements
Routine maintenance (DB backup, Ensuring free space for the DB, etc )
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 28/37
Transaction Management A transaction is a collection of operations that performs s single logical
function in a database application E.g. Money transfer from an account to another
Each transaction must satisfy the following properties: Atomicity: all -or-non e, which mea n s tha t the t r a n sa ction successfull y
co mpl etes if and only if all the t a sks o f the t r a n sa ction s a r e successfull yco mpl eted
E.g. in case of a money transfer, the transaction is valid if both debit and credit operations occur.
Consistency: the final state of the system must be correct and compatiblewith the previous status before the transaction is made.
E.g. after a credit transaction, the balance must be updated accordingly to theoperation
IIsolationsolation. It ensures that concurrently executing transactions are isolatedfrom one another, so that each transaction has the impression that no other transaction is executing concurrently with it.
That is, for every pair of transactions T i and T j , it appears to T i that either T j , finished execution before T i started, or T j started execution after T i finished.
Durability: the value in the database must persist, even in case of a system failure.
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 29/37
Database System Structure A database system has several sub-systems
Transaction Manager Responsible for ensuring that the database remains in a
consistent (correct) state despite systems failure.
Ensures that concurrent transaction execution proceed without conflicting
Query Processor Compile and executes DDL and DML statements
Storage Manager
Provides the interface between the low-level data stored in thedatabase and the application programs and queries submittedto the system
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 30/37
Application Architectures (Most of) Database systems are accessed
remotely through a network
The Client/Server Model Client machines, on which remote database users work
Server machines, on which the database system runs
DatabaseClient machines
Server machines
Network
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 31/37
Application Architectures Two-Tiered Architecture
The application is partitioned intoa component that resides at theclient machine
It remotely invokes the databaseserver machine through querylanguages statements
E.g. using ODBC, JDBC for interaction between the client andthe server
Three-Tiered Architecture The client machine acts as a
front-end and does not containany direct database calls
The client machinecommunication with the server application through an interfaceof forms (not direct queries)
The server applicationcommunicate with a database
system to access data
application
User
Database systems
NetworkNetwork
Two-Tiered Architecture
Application client
User
Database systems
NetworkNetwork
Three-Tiered Architecture
Application server
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 32/37
Instances and Schemas Instance of a database
The collection of information stored in the database at a
particular moment is called an instance. Schema of database
The overall design of the database is called schema.
Physical Schema
Describes the data design at the physical level
Logical Schema
Describes the data design at the logical level
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 33/37
Review Terms Database management
system (DBMS)
File Systems Data inconsistency
Consistency constraints
Data views/ data
abstraction Database instance
Data models ((E-R), Relational)
Database languages (DDL, DML)
Data Dictionary
Metadata
Application program interface
Database administrator
Transactions
Concurrency Client and servers machines
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 34/37
Exercises Q.1 List four significant differences
between files systems and a DBMS
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 35/37
Exercises Q.2 What are the steps that you would take in setting up a
database for a particular enterprise? R2.
Collecting the required information that must be stored in thedatabase
Define the structure of the schema of a database, which definesthe logical and physical structure of the data
Define the method for manipulating the database Establish the relation between data Granting authorization for data access for the case of multi-user
database systems Creating different views of the database for different users of the
database
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 36/37
Exercises Q.3 What is the purpose of having a
DBMS?
R3. the primary goal of a DBMS is toprovide an environment that is both
convenient and efficient for people touse in retrieving and storinginformation
8/7/2019 chapter1-Introduction to DBMS
http://slidepdf.com/reader/full/chapter1-introduction-to-dbms 37/37
Exercises Q.4 Define a transaction. Explain the
meaning of atomicity and illustrate it on example.
R4. A transaction is a collection of
operations that performs s single logicalfunction in a database application